Credit : Moving tip# 28
Few posts back, I’d mentioned that how one can move the WordPress blog from one web-host to another in one of the simple ways. However, there is one more simple and quick way of moving the WordPress blog and I would like to share it with you all to ensure that in case you face the problem of changing the host then you won’t have to waste enough time in the process and that you concentrate more on writing.
Easiest and quickest way of moving WordPress blog from one web host to another:
Prerequisites of the whole process -
1. SSH should be enabled on both the webhosting accounts.
2. Access to phpMyAdmin on both the accounts.
3. SSH Client – For windows you can check the list of SSH Clients from here. Linux and Mac users can live with plain ol’ Terminal.
4. FTP access (not required though as such)
Important Assumptions -
1. domain of blog we are moving : http://mayank.info
2. Old Host’s folder structure – /public_html/mayank/
3. New Host’s folder structure – /www/blog/
4. Username/Password on Old host – admin/pass123
5. Username/Password on New host – newadm/newpass1
6. SSH address of the old host – 184.108.40.206
6. SSH address of the new host – 220.127.116.11
The Process -
1. Making the backup : The first step is to ensure that we make the backup of all the files and for that we will use the SSH of the original web host and will navigate to the folder where wordpress is installed and will run these commands to do make the back up of the files – Type the following commands in the SSH client.
- ssh firstname.lastname@example.org (this will connect you to the old server, when you’ll press enter after this command, it will ask for the password, just enter the SSH password which in our dummy case is pass123)
- cd public_html/mayank (this commands will bring you to that particular directory where wordpress is installed on our old host)
- tar -cvf wholeblog.tar ./ (this will ensure that all the files in the folder called mayank gets packed in a file called wholeblog.tar)
- exit (this will disconnect you from the old server)
2. Moving the backup to new server : Now that we have created the backup, it’s time to move the back up to the new server and unpack it too. For that we’ll follow these steps -
- ssh email@example.com (again this will connect you to the new server)
- cd /www/blog (this takes us to the folder where we’ll move the blog).
- wget http://mayank.info/wholeblog.tar (this will fetch the file from the old host to the new host)
- tar -xvf wholeblog.tar (this will unpack the file and all the files will appear just the way they were on old host).
3. Make the changes in wp-config file – Now that we have unpacked all the files, we will make the changes in the wp-config file to ensure that it points to the new database location. We’ll need to change the username, password & the database server information. It’s similar to the way we install the new wordpress. Although, we’ll make the changes directly through SSH Client with the help of these commands -
- sudo nano wp-config.php (this will open the editor called nano and you’ll be able to see the content of wp-config.php in it.
- Make the required changes i.e. database username, password & database location and save and exit.
- exit (this will disconnect you from the server).
Note : If you are not comfortable enough with Nano editor then the alternate to this can be that you connect with FTP of your new server, download the wp-config.php file, edit the file and then re-upload it.
4. Making the database backup – It’s the time to make the back up of the database and I’ve not seen any better guide than the one mentioned at WordPress Codex. It tells you all the possible ways of making the backup. Although, I will suggest that you should follow the phpMyAdmin section in this guide.
5. Change the nameservers : Now is the time to change the nameservers. So point the nameserver of your domain to your new webhost.
6. Restoring the database backup – Again, I would refer you to the WordPress codex as it has a very good information on restoring the database backup through various ways.
7. DNS Propagation – It usually takes around 24 hrs. for the DNS propagation to be complete and you’ll be able to see your blog up and running and that in exactly the way it was before on the old host.