Table of contents
There comes a time while owning a website when it needs to be moved to a different hosting provider.
In this article I try to go over a few things like why you want to transfer your WordPress site, what steps you should do before that, tools that will help you move it faster, how to do it manually.
Reasons to transfer your website
- Better performance. Most clients that I’ve worked with started by using an inexpensive shared hosting solution that might perform well for some basic needs. I mean if you only have a site that is not driving heavy volumes of traffic, then this option is good enough.
Traffic volume is not the only thing that can make you purchase a better hosting solution. If you run a presentation website (your portfolio), first impressions matter. Your site will need to be quick and snappy to make a good impression.
- Better pricing. This usually happens when you’re already using a premium type of hosting, something that is a bit more expensive. At that point you might want to look around and see if there are some other options that provide similar performance at a better price. You might have purchased the domain and hosting as a bundle initially, but you now realize that it’s not the best option.
- Better features. You might want to deploy certain technologies to your site that are not available on your current hosting plan. SSH, backups system, staging environments, and Let’s Encrypt are the most common things that you might need, and some hosting plans might not support them.
- More space. This might also be achieved through your current hosting plan but refer to the “Better pricing” part from above, you might get a better deal in a different place.
To-dos before transferring the website
- Backup your files
If you have cPanel access, go into public_html, archive all the site files and download that archive. If you only have an FTP connection, go in with Filezilla and download all the available files in public_html.
Most websites are directly installed in the public_html folder; if you used a different structure you can download that specific folder.
- Backup your database
Using cPanel you can go to phpMyAdmin and export the database that is associated with your website.
- Check new hosting credentials. Make sure you have the correct login details for all the things that you need: domain (because nameservers will need to change), Cloudflare (if used) and new hosting.
Manually moving your WordPress site
Upload the files
Use cPanel to upload the archive that you created at the backup step and decompress it in public_html or go with Filezilla and upload the files directly to the main folder.
If you assigned a different folder to that domain on the new hosting, make sure to upload it there.
Import the database
You now need to import the database on the new server.
Go to cPanel > MySQL databases. Create a new database, name it whatever you like. Create a user and associate it with the database. Keep all those details (database name, user, password) handy because you’ll need them later on.
Once you created the new database, go into phpMyAdmin and select the newly created DB, click on Import, and select the one that you downloaded previously when you backed your database. After this step is completed you should have the content from the old database imported to the new one.
Edit wp-config.php
Now that you have the files and DB in place, you need to update the wp-config.php file to use the correct details.
You can go ahead and edit the wp-config.php file directly from cPanel or via Filezilla.
We’re interested in this part:
/** The name of the database for WordPress */ define('DB_NAME', 'database_name'); /** MySQL database username */ define('DB_USER', 'database_user'); /** MySQL database password */ define('DB_PASSWORD', 'password'); /** MySQL hostname */ define('DB_HOST', 'hostname');
- Change the database name to the one you just created
- Change the username to the one you associated with the database
- Change the password to the new user password
- Hostname in most cases should default to localhost unless the hosting provider tells you otherwise.
Update DNS
After you complete all the above steps you still need to point the domain to the correct server, because now it still points to the old one.
What you need to do is go into your domain registrar and update the Nameservers.
Each hosting company will provide you with 2 nameservers that you need to update for the changes to take effect and make the domain point to the correct server.
This will take up to 24 hours. There is a way to make it faster and not take 24 hours, check the “Use Cloudflare to resolve DNS” step.
Using plugins to move a WordPress site
There are 2 plugins that I’ve used a lot, also mentioned in the How to set up a WordPress staging environment article.
- All in One Migration is my go-to plugin when it comes to moving websites. Check it out, it has an amazingly simple way of dealing with website transfer. The one thing that you need is a WordPress installment ready on the new server. A fresh and empty WP install will work.
- Duplicator. For this one you will have to upload on the server the 2 files that the plugin generates and after that go through some simple steps to setup the new install.
The good thing about this method is that you don’t need a WP installment ready on the new server. You will need an empty database and user.
Use Cloudflare to resolve DNS
A faster way to solve the DNS, nameserver update, would be to use Cloudflare.
Cloudflare has a bunch of other advantages, but the most important one on the free version is that it quickly resolves the DNS when someone tries to connect to your website, no matter the part of the world they are from.
If you don’t use Cloudflare already, I would recommend setting up an account before moving to the new hosting provider and after that you just have to change your record in Cloudflare to point to the new IP.
If you’re interested in updating your A record for the main domain, other records in there should be CNAME records pointing to that A record, so no need to mess with them.
Cloudflare DNS update takes place in a matter of minutes and you will be able to test the new hosting right away and not wait for 24 hours.
Final thoughts
The steps above should help you move your WordPress site to a new server from a different hosting provider.
In most cases following those steps should be enough to move your site. As you can see, I prefer to do the move while I still have the domain pointing to the old server and change the DNS at the very last. You can do it the other way around: you can point the domain to the new server before starting to do the moving.
Your site should still be accessible on the new server via the dedicated or shared IP. So, you should be able to check if things are ok before updating the DNS.
Moving the content first and updating DNS as the last step will ensure for little downtime.
If you use Cloudflare it doesn’t matter that much, because the change will be pretty fast when you update the DNS.