Either you change host, or if you are hosting at home you want a faster server, there are many reasons why you would need to move your WordPress site. Here we will learn how to do this.
The Situation
When I have build my site (www.paulgeanta.com) I decided to host it at home. If you are interested to do the same thing please read http://192.168.111.144/host-your-site-at-home/
The server I installed was based on a virtual Machine on a Synology 718+. This is usable without too many problems, but the processor power is limited. The Synology 718+ comes with a 1.5 GHz Intel Celeron J3455 Quad-Core processor. It is perfect for a test or internal server in fact I have my Domain Controller running on a Synology VM ), but for a server facing the world, it might be a little slow, and I want my users to have the best experience possible.
I decided to move the site on a Dell T-100 Which has an Intel® Xeon® 3 GHz and 8Gb RAM. This should be more than enough to provide a good experience for a WordPress site without any issues.
After I installed Linux, Apache, MySQL, PHP and WordPress on the new hardware (please follow the links below if you need to know how this is done)
I get on with the next step (Moving the site). In order to continue please make sure you have done all the above installations on your new server.
We have at this moment 2 websites that side by side look like this:
And we want to have on the right the same thing as on the left.
The first thing we will do is to backup the database and the files from the original website. For this open a terminal on your original server and follow the steps below:
Backing up the files
Run the following commands:
sudo su cd /var tar -cvzf www.tar.gz www scp www.tar.gz username@xxx.xxx.xxx.xxx:~/
(where username is your username on the new server and xxx.xxx.xxx.xxx is the new server ip)
If you get an unable to connect message it is probably because on the new server, you did not install openssh-server. To do this open a terminal on the new server and run:
sudo apt-get -y update sudo apt-get -y install openssh-server
and once the installation is complete retry the scp command.
Backing up the database
If you have followed my how-to for installing wordpress, your WordPress database is named wordpress and its user is also wordpress if not please adjust the following command accordingly.
mysqldump -u wordpress -p wordpress > wordpress.sql
The first wordpress is the username and the second is the database name. The 3-rd one is the file that will contain the backup.
Then run:
scp wordpress.sql username@xxx.xxx.xxx.xxx:~/
(change username with the username on your new server and xxx.xxx.xxx.xxx with the new server IP)
You can now delete the backup files you created on the old server:
rm /var/www.tar.gz rm wordpress.sql
Restoring on the new server
Now login to the new server and start a terminal. Become root using “sudo su”.
Restoring the database
To restore the database (and I assume that the configurations on both machines are identical) use the following command:
mysql -u wordpress -p wordpress < wordpress.sql
Restoring the files
Run the following commands (you should already be root):
mv www.tar.gz /var cd /var/ rm -Rf www tar -xvzf www.tar.gz rm www.tar.gz reboot
Change your DNS or port Forwarding to point to the new server (please contact me any time if you need help with this part) and turn off your old one.