Migrate WordPress to New Server
How To Migrate a WordPress instance to a New Server
Backup Site internally
(slice1)
sudo cp -Rf /var/www/www.example.com /home/username/sites
Backup MYSQL database
mysqldump -u root -p www_example_com > www_example_com.sql sudo mv www_example_com.sql /home/username/sites
It is convenient to put everything into one directory so all files can be moved at once. I use /home/username/sites
Copy site and SQL file back to local machine
I use Rsync instead of FTP for security
copy site from server
(slice1)
sudo rsync -azv -e ssh username@slice1.example.com:/home/username/sites /home/username/sites/
copy site to server
(slice2)
sudo rsync -azv /home/username/sites -e ssh username@slice2.example.com:/home/username/sites/
Move Site Internally
(slice2)
sudo mv -Rf /home/username/sites /var/www/
Login to MySQL and create database www_example_com
Exit MySQL
Import Database
mysql -u root -p -D www_example_com < www_example_com.sql
Create Virtual Host
sudo vi /etc/apache2/sites-available/www.example.com
copy this code into the file
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName www.example.com
ServerAlias www.example.com
DocumentRoot /var/www/www.example.com/
</VirtualHost>sudo a2ensite www.example.com sudo /etc/init.d/apache2 restart
WordPress Migration Errors
If you see the error message
- Upload folder is not writable. Export and file upload features will not be functional.
Immediately check (in wordpress) Settings > Media > Store uploads in this folder : the path to the folder may be different than on the prior server