Businesses will migrate their website from one hosting provider to another for various reasons. Could be because the hosting provider is putting the business at risk or possibly because the hosting provider is no longer the right fit for that business. No matter the reason, if you’re looking to migrate your WordPress website, there are a few things you’ll need to take into account.
In this article, we’ll go over how to properly migrate your WordPress website so that you can avoid any downtime or data loss.
Step 0: Schedule time
Before you tackle the following steps, be sure you’ve scheduled time in your calendar. The entire process could take anywhere from 30 minutes to a few hours depending on the size of your website and the speed of your internet (to download and upload files).
Further, during the migration process, you’ll want to be sure it is during a time no one will be making modifications to your website. This includes editing website pages, blog posts, making orders, leaving blog comments, etc. Any data that is changed after you start the database migration process will be lost.
Step 1: Make a full backup of your website
A full backup of your website should include all of your WordPress files as well as your database. There is a good chance your current hosting provider provides you with backups, but you’ll want to be sure you can run a new backup, on-demand, so you have all of the data from the moment you’re ready to start this process.
If you’d like to create your own backup, you can use a plugin like Updraft Plus. Just be sure you’re able to download the entire backup including all of your files and the database.
Step 2: Import your database
With a fresh backup of your WordPress install, downloaded and unzipped (if necessary) on your local computer, you’ll first want to import your database to your new hosting provider.
The steps needed may vary from hosting provider to hosting provider. Some will do this for you and those that don’t will likely have a guide for how to do this within their specific platform. If not, it might be a little tricky to figure out, but they likely have phpMyAdmin running. If so, and you can figure out how to gain access to it, you’ll first want to create a new database. Take note of the database name as well as the user and password that has access to it. You can then login to phpMyAdmin and follow these steps to import a database with phpMyAdmin.
Step 3: Upload your files
Now that you have your database imported, it’s time to upload your WordPress files.
You can do this via (S)FTP or, if your new hosting provider provides a migration plugin, you may be able to use that as well. If using (S)FTP, you’ll first need to connect to your new server with an FTP client using your (S)FTP credentials. You can read up on what an FTP client is and find one that works for you from WPBeginner.
Once connected, navigate to the directory where WordPress has already been installed or the root of your hosting directory (typically named public_html or www). If WordPress is already installed, you’ll want to be sure only to upload the wp-content folder from your previous backup, replacing the existing wp-content folder. Otherwise, if WordPress isn’t already installed, you can upload your entire backup (minus the database file you used in the previous step).
The upload process could take a bit of time depending on the size of your website files (i.e. uploads, themes, plugins) and your internet connection speed.
Step 4: Update wp-config.php
Once the upload is complete, you’ll need to update your wp-config.php file with the database details you noted when creating the database. You can do this by downloading the wp-config.php file that exists already on your server and edit the following lines being sure to replace “YOUR_DATABASE_NAME”, “YOUR_DATABASE_USERNAME” and “YOUR_DATABASE_PASSWORD” with the appropriate values for your new database:
define('DB_NAME', 'YOUR_DATABASE_NAME');
define('DB_USER', 'YOUR_DATABASE_USERNAME');
define('DB_PASSWORD', ‘YOUR_DATABASE_PASSWORD');
Step 5: Update DNS
Okay, the moment of truth. At this point, you should have your entire WordPress install copied over to your new hosting provider. But, in order to view it at your new provider, you need to tell the Internet where to find this new copy. This is done with your DNS records.
DNS is what tells the Internet where your website is hosted. So, you need to update the DNS records for your domain name to point to the new hosting provider’s servers. This will vary depending on where your domain name is registered but, generally speaking, you login to wherever you purchased your domain and find the DNS management area. You then want to create or update an “A record” that points to your new hosting IP address (you can get this from your hosting provider) as well as a “CNAME” record for www that points to your root domain (i.e. yourdomain.com).
It may take up to 24 hours for these changes to propagate across the internet so don’t panic if things look broken at first!
If you’d like to view your site BEFORE updating DNS (or while you’re waiting for DNS to propagate), you could modify your HOST file to do so. If you’d like to modify your HOST file and you’re using Windows, the file is located at C:\Windows\System32\Drivers\etc\. If on a Mac, the file will be located in /private/etc/hosts. No matter which operating system you’re on, you’ll need to open your HOST file with a text editor like Notepad as an administrator.
Once open, you should see two columns of information, separated by a space. As an example, there should be a line in your file that looks like:
127.0.0.1 localhost
The format is IP ADDRESS _SPACE_ DOMAIN NAME. You’ll want to add a line to the bottom of the file with your new IP Address and your website domain (including www if you’re using it). So, the line will look like:
64.24.128.24 yourdomain.com
or
64.24.128.24 www.yourdomain.com
Obviously, be sure you replace 64.24.128.24 and yourdomain.com with the appropriate values for your new hosting environment.
You can then save and close the file. If you now try to visit your website in any browser using www.YOURDOMAIN.com. You should see your WordPress site being loaded from your new hosting provider!
Step 6: Test your website
Alrighty, everything is up and running, time to test everything out. Visit your website being sure to click around through all of your pages. Test your contact forms, order forms, etc. to confirm everything is working exactly as you’d expect.
If you see any errors, broken images, or otherwise, it’s possible a file (or more) got lost in the shuffle or a setting wasn’t properly migrated. If this is the case, you can decide to revert back to your old host or troubleshoot to figure out what the issue is.
Otherwise, if all looks good, give yourself a high five! If you modified your HOST file, but haven’t updated DNS yet, be sure to revert the change you made to your HOST file and review updating DNS in the step above.
Step 7: Cancel your old hosting account
You did it! Your WordPress site has been successfully migrated to your new hosting provider. Be sure to monitor things for the next few days (or weeks) as you might still run into a few small hiccups here and there. But, once you feel confident things are working as expected, you should be sure to cancel your old account so you’re not paying for hosting with two providers.
Keep in mind, if your old provider was providing email hosting or other services as well, you’ll want to be sure all of those services are provided by your new hosting provider or find new homes for those necessary services.
Conclusion
Overall, the process should be pretty seamless and straightforward, but I hope this guide has helped you fill in the gaps and given you the confidence you need to do your WordPress migration yourself and avoid some of the common mistakes.
If you find you’re overwhelmed by the process of finding a new hosting provider or migrating your site to a new provider you’ve already chosen, we can help you with the entire process. We also provide fully managed WordPress hosting services which includes white glove migrations to our servers at no additional cost (or stress) for you.