Moving WordPress safely
Migrations aren’t just for birds looking to find warmer climates. Our websites can undergo them as well, at our behest of course. Although they won’t be in search of warmer climates like their migratory counterparts, their new home will be a place to snuggle into.
Unlike avian migrations, this process can be completed in a couple of minutes. Think of it teleporting your website to its new home instead of flying it there. All you have to do is pull the correct dials, levers, and press the right buttons and you’ll be set.
So, in this guide, we’ll show you how to safely migrate your WordPress website so you don’t leave even a feather on the other side. Strap in and follow along.
- Which migration option is best for your WordPress website?
- Pre-migration checklist
- Post-migration checklist
- Migrating WordPress manually
- Pre-migration checks
- Compress and download your WordPress installation
- Download a copy of your database (DB)
- Upload your WordPress files to your new host/server/domain
- Create a new DB
- Import the old DB
- Update the WP Config
- Update the installation and site url in the DB (For new domains/sub-domains)
- Update nameservers
Which migration option is best for your WordPress website?
There’re many factors to consider when deciding which method to use to migrate your WordPress website. The most important ones are the size of the database, the size of your site files and folders, and, believe it or not, your level of confidence. Let’s take a look at each of these.
Size of DB
Most plugins have a limit to the size of the database with which they can work, especially the free plugins. So, if you’re looking to use a plugin, check the size limits for the plugin as well as your database size.
To check the size of your database in phpMyAdmin, click on your database, then look at the bottom of the size column.
Size of website
Next up, you’ll want to check that the plugin can handle the size of your website. To do this in cPanel, click on “Disk Usage” then look at the total size of your “public_html” folder.
If you have other websites included in your “public_html” folder, you’ll want to dig further. Simply scroll further down the page and click on the arrow next to “public_html”.
Level of confidence/knowledge
Finally, you’ll need to decide whether you’re comfortable doing it the manual way or if you’d prefer to use a plugin. If you’re not comfortable doing it manually, and your website and database are too large for the free plugins, you may either need to pay for the premium version of the plugin or just speak to your hosting company. Most hosts will assist with migration for a small fee.
Whether you’ve decided to go the manual route or use a plugin, there are a few things you need to check before you start downloading your files and database.
- Check the login details for both control panel accounts. Make sure you’re able to log in to the control panel, as well as access the account via FTP. You’ll need both in order to download/upload the SQL file as well as the website files/folders.
- If you plan on downloading the files and folders without compressing them, then you can skip this step. If you plan on compressing the site, check that your storage disk has at least 40% free space – if it doesn’t, ask the host for a temporary disk increase.
- If you plan on moving the domain across to the new host, in cPanel set TTL for all DNS zones to 300 or as low as the host allows. This ensures the least possible downtime.
- Request wp-admin login details and check that they’re correct. Even if you’re not using a plugin, you’ll need this information in order to disable security and cache plugins before you download anything.
- Check that the correct PHP version is enabled as well as the PHP extensions necessary for the website to run. We’ve received many tickets in the past due to missing PHP extensions which end up either breaking the website (don’t worry, this isn’t permanent), or just not displaying the website correctly.
While this section should be closer to the end of the article, we’ve decided to put it here so that you are aware of these steps before you begin.
- Check the site before changing nameservers. You can edit your “hosts” file to point the website to the new server’s IP address. This’ll save you a lot of headaches if anything goes wrong with the migration. The IP address will either be in your welcome email, located under “General Information” in your cPanel account, or your new host will have it.
- Make sure you’re able to log in to the site without any issues.
- Check all the pages to make sure the site has migrated properly.
- If need be, do a search and replace or fix any broken URLs. This step shouldn’t be necessary if relative URLs were used.
Migrating WordPress manually
So, you’ve opted for the manual route. If you have a basic understanding, this path is simpler. If not, you could learn something by doing it yourself.
In addition to the pre-migration checks above, there’re a few WP specific tasks to do before you start your migration. Let’s take a look at each.
Backup and cleanup
Now’s the best time to do some spring cleaning on your website. Before starting, do a full backup, just in case, something goes wrong with an update. Clean out old plugins that are no longer in use. Update plugins and WordPress core to the latest version. Then, get rid of any old posts or pages that are still in draft status and won’t ever be published.
Disable security and caching
Next up, disable any security plugins still in use. Some security plugins cause issues with migrations, whether manual or no, so it is better to simply disable them than have to deal with issues later. Similarly, you’ll want to disable any caching plugins as well. Don’t delete them – just de-activate.
Compress and download your WordPress installation
Now that you’ve cleaned and updated the site, it’s time to start the actual migration. As mentioned previously, you’re either going to compress and download the files or download them as is. Either way, you’ll need an FTP application, like FileZilla, to access the server and download your files.
Log in to the old (current) server using your FTP application of choice. On the left pane is a view of your local files and folders, and on the right pane is a view of your server.
On the left, select the place where you want to store your website, and on the right, navigate to your “public_html” folder and select the folders to download.
Then, right-click on the selected files/folders and click “download”.
While you’re waiting for the download, let’s move on to the database download.
Download a copy of your database (DB)
In cPanel, navigate to “phpMyAdmin” and click on the link/icon to open.
Select the database you want to download on the left-hand side, then click the “check all” button at the bottom of all the tables.
Click on the dropdown and select “Export”. Don’t click “Empty” or “Drop” as this will delete all your database tables.
If you don’t know which database you need to select, you can find the name of the database in your “wp-config” file.
In cPanel, it will be the DB_NAME prefixed by your cPanel username. So, in this case, it would be “mycpanelaccountuser_mcwpdb” -> This may come as news to you, but the example in this image is made up.
On the next page, just select “Go”. This’ll download a SQL file of your database to the default download location. This is usually your “My Downloads” folder.
Upload your WordPress files to your new host/server/domain
Once your downloads are done, you can log out of the old server in your FTP application and log in to the new one. The steps are the same as the download, just in reverse. So, on the left-hand side, navigate to where you saved the downloaded website files and folders, select them all, then right-click and upload them to the “public_html” folder on the right-hand side.
Create a new DB
Creating a new database in cPanel is a breeze. Navigate to the “MySQL Databases Wizard” and follow the prompts. Store the database name, database username, and database password in a safe location as you will need it in a few.
- Enter a new database name, click “next step”.
- Enter a new username.
- Select the “password generator”, copy the first password, then click on “generate” again, and paste the first password at the end of the second password.
- Copy the entire password, then click on the checkbox and “use password”.
- Click “create user”.
- Select the checkbox marked “All privileges” then click “Next Step” at the bottom.
That was pretty easy, right? Hopefully, you saved those details. If not, you can go back to “MySQL Databases” for the DB name and username. The password will need to be reset though.
Import the old DB
Now, it’s time to import the old database tables into the DB you just created. Go to phpMyAdmin, select the database on the left, then click on “Import” at the top.
Click on “Choose file” and select the SQL file you downloaded earlier. If the (Max: #MiB) next to choose file is less than your SQL file, you can increase this in your PHP settings. If this doesn’t work, your host will need to increase this for you.
Once you’ve uploaded your SQL file, click on “Go” at the bottom.
Update the WP Config
With the website and database uploaded, it’s time to connect the website to the new database. Locate the “wp-config” file in your “public_html” folder, and enter the new DB name, DB username and DB password.
For new domains/sub-domains (Update the installation and site url in the DB)
If you’ve changed the domain of your website, whether moving from localhost, sub-domain, or an entirely different domain, you’ll need to update the URL in the database.
Go back to phpMyAdmin, locate the “_options” table (it’ll be prefixed by your cPanel username) and edit the first two rows. Just make sure these are the “siteurl” and “home” rows.
Update the URL in the “option_value” field, then click “Go”.
Your website is almost live, there’re just a few more checks you need to do to make sure everything went smoothly.
Update “hosts” file
To view your website before updating nameservers or transferring your domain, edit your “hosts” file to point to the new IP address. We can use Notepad++ for this.
You can find your “hosts” file by going to C: > Windows > System32 > drivers > etc then open the file with Notepad++ (with administrator privileges).
Enter the IP address followed by a space and your website URL. If your website uses a sub-domain (www), enter that on a separate line as well.
Save the “hosts” file – if you get a notification saying you need to be in Admin mode, simply click “yes” and save again.
Now you can log in to your website and enable the plugins you disabled previously, then move on to the post-migration checks as listed earlier in this article.
Once everything’s ready and you’re happy that your WordPress website was migrated over successfully, you can update your nameservers to point to your new hosting provider’s nameservers. We generally do this step as it reduces downtime even further when it comes to transferring the domain.
And that’s how you migrate your WordPress website the manual way. Reading this, it may seem like a lot, but in reality, it’ll take you a few minutes to do. The longest part is the download and upload of the website itself.
Don’t forget to change your “hosts” file back to the way it was before.
How to migrate WordPress manually
- Back up your data and clean up outdated plugins, as well as old posts that won’t be published.
- Disable security and caching to avoid issues
- Compress (optional) and download your WordPress installation.
- Download a copy of your database from cPanel.
- Upload your new files to your new host/server/domain.
- Create a new database.
- Import the old database into the new one.
- Update the WordPress config.
- For new domains and sub-domains: Update the site URL in the database.
- Perform post-migration checks with these extra steps: Edit your “hosts” file and re-enable your plugins.
- Finally, update your nameservers and revert your “hosts” file back to previous state.
- The WHOIS who and what’s what of the internet
- Acronis Cloud Reseller Setup
- How to install Acronis Backups
- Horde Temporarily Disabled on all Web Servers
- How To Use Ansible to Deploy Docker Containers on Debian 11
- LiteSpeed vs NGINX vs Apache
- Deploy Kubernetes Cluster on Debian 11 with Containerd
- How Do Our Reseller Programmes Work?
- How To Install WordPress on Docker: Windows and Linux
- How to Fix Broken Links on Your Website