I always wanted to post a tutorial to move WordPress to new server same domain a long time ago, but for some reasons I haven’t done it.
So in this tutorial, we are going to move WordPress to new server using same domain. I am using wpdemoblog.com which is currently hosted in HostGator (for the demo purpose only) to BlueHost. Obviously, you can replace wpdemoblog.com with your domain name.
This tutorial can be used too from BlueHost to HostGator, or any hosts, I just use them for the demo.
So say, you have a blog now in HostGator, with the name wpdemoblog.com, and you want to move it to BlueHost.
What you want to do first, either move the domain from HostGator to a domain registrant like Namecheap, or bring the domain to BlueHost (as the new host). (While sign up the hosting plan, you need to specify, you already have the domain, and type wpdemoblog.com in your domain box.)
I would personally register the domain in namecheap.com, because it is easier to collect all of my domains, if you have or want to have more than one websites.
The point here is, do not delete the old website first, and do not change the dns server to point to your new server first, before your website is setup and running exactly the same like in your old server.
I know it’s a bit tricky to do this, but it’s the safest way, if you care about the down time of your website.
So let’s get started. I am using cPanel, you can use FTP client if you want to, I just use cPanel because it’s fast.
How I Usually Move WordPress to New Server Using Same Domain
1. You need to follow my other tutorial how to manually backup your entire website in this page first.
Without this, we can’t continue.
Say, the blog files are compressed under blogbackup.zip (example name) files, and the database is called dbbackup.sql (example file name)
2. So once you have the site backup, the .zip files and the .sql database, you can go to your new webserver’s cPanel, and go to File Manager.
3. Upload the blogbackup.zip file here, then extract the files in the same path.
Delete the blogbackup.zip from your cPanel.
4. Now, in cPanel Home, go to “MySQL databases” to create a new database, a new database user, and a database user’s password.
Add the user to the database.
5. Now, go to phpMyAdmin, and import dbbackup.sql the database you downloaded from step 1.
6. In your site’s directory, edit wp-config.php and replace the old database data to the new ones we created on step (4) above.
Also, I recommend changing the secret key by going to this URL : https://api.wordpress.org/secret-key/1.1/salt/ and refresh your browser several times to generate the keys.
Replace the old secret keys in wp-config.php with this new one, and click “Save Changes” button.
7. Now, we want to see how our site looks like in the new server, so we need to view it locally in our computer using the shared IP address of the new server, while the old website is still running in the internet.
You can find the Shared IP address inside your cPanel home left sidebar.
Copy this shared IP address.
Add the shared ip address on your cPanel and your domain, like in this screenshot.
This code on hosts file, will let us view our site only in our computer.
9. Now, open your site in your browser, it should show the website in the new server.
Note: at the same time, your old site is still alive in older server, because we haven’t changed the DNS to the new ones. You’re able to see this website in the server, because we just modified our hosts file in previous step above.
In the video, I edited the footer by adding the new server’s name just to make it easier for me, which site is with the new server, and which one is with old server.
10. Update the DNS server for your domain when the new server website is all setup.
11. Repeat the step 8, we want to delete the two lines we added before, to view our browser without new server’s IP.
12. If you see still, the old server website, this means, the domain isn’t propagated yet, it can take a few minutes to a few hours. But because we still have old website in the old server, and also in the new server, your website won’t have downtime.
Once you are sure that the website is already running in the new server, you can delete the old website. (make sure you have the backup first.)