It sometimes happens that the hoster of confidence, that to which we have entrusted the management of that site, decides to close its doors, or radically change the conditions of the hosting plan.

In these cases there is little to do. One solution is to change hoster. In this article we take care of keeping the Apache settings exactly as they were set on the old server. You must have SSH access to the machines.

1_ We copy the Apache configuration files:

# ssh username@oldserver
# scp /etc/apache2/sites-available/ user@newserver:/etc/apache2/sites-available/

This command will copy the Apache settings from the old to the new machine. Now we enable all the sites copied with symbolic links for each file .config copied to sites-enabled.

# ln -s /etc/apache2/sites-available/ /etc/apache2/sites-enabled/

Or use the command a2ensite that will do the same thing.


We restart Apache for the changes to take effect.

/etc/init.d/apache2 restart

2_ We copy the site

# scp -r /var/www/ username@newserver:/var / www

All major CMS (or maybe all CMS) they are made from files, and with this command we copied them all. It must be said that the content, comments, site categories and settings are saved separately in a database. So let's copy that too.

3_ We migrate MySQL

We will run these commands being logged into the old server.

# mysqldump --all-databases -u root -p > backup.sql
# scp backup.sql username@newserver:/home/username/
# ssh username@newserver
# mysql-u root-p < backup.sql

What we did here was to create a backup of the database on the old server, transfer it to the new one and populate the new database with the contents of the old one.

4_ DNS migration

Restano solo da reimpostare i DNS in modo che puntino all’IP del nuovo server. Questa operazione è da concordare con l’hoster.

  The "Mauro Paravia" closed its doors

A word of advice. Prima di rendere tutto operativo è opportuno testare la riuscita delle operazioni ad esempio in un sottodominio:, per essere sicuri che tutto funzioni.


I keep this blog as a hobby by 2009. I am passionate about graphic, technology, software Open Source. Among my articles will be easy to find music, and some personal thoughts, but I prefer the direct line of the blog mainly to technology. For more information contact me.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.