How to properly migrate a WordPress site

Intro

WordPress store URLs of the pages, articles, media and all other content in database as absolute paths.

This mean that you need to update URLs when the site address changes, the simple database copy may lead to errors or increased load time, because of increased number of load requests.

For a proper migration, you have to copy the files to the new location and migrate the database. To copy the files you can use the hosting panel File Manager (if available), FTP or SSH. For the database migration – check the instructions bellow.

Coverage

This article cover the following situations:

  • Migration to a new domain;
  • Migration of the site form some dev location to a production one;
  • Switching the site from HTTP to HTTPS;
  • Switching the site from www to non-www, or from non-www to www;
  • Sometime it may be required for migration from one hosting environment to another, even if the domain is not changed (but the location path changes).

Database migration

You can find a lot of instructions on the internet that will say that it is just enough to change two URLs in options table in database, hardcode new site URL in wp-config.php or make some redirections via .htaccess file.

It is not!

The only one good solution is to update all the links in the database and in site files (if you use somewhere absolute URLs).

Also, you can’t just replace the URLs in the database, because some components store the URLs as PHP serialized strings and that will broke the site.

Before migration, make a complete site backup (database and files), disable any security and caching options of the site, clear any existing temporary or cache files.

The most efficient and easy for migration is to use a special plugin for migration. There are a lot of them. The one I recommend is WP Migrate DB. It allows you to define the migration scenario, then exports the database with applied changes.

Steps

  1. Install and activate the plugin, go to Tools, Migrate DB.
  2. Configure the “Find” and “Replace” rules (Enumerate all the combinations you have in the database, replace all of them with a single valid new domain URL).
  3. Click on “Export”, save the updated database.
  4. Go to Database management tool (ie: PHPMyAdmin), delete all the tables related for WordPress (be aware if you have some tables not related to WordPress in the same database!).
  5. Import the migrated database.
  6. Check the WordPress theme for any absolute URLs that require update.

Conclusion

WordPress is a great CMS, simple to use and administrate, but a migration should be done correctly to avoid problems.

If you have some questions – don’t hesitate to ask me. If you don’t have time to spent on that – hire me as freelancer!
Last update: 2017/01/30

Change WHM/cPanel server IP address

If you migrated or clonned a WHM/cPanel server, changed or just added another IP address, you need to update the IP address(es).

If you need to add the new IP address by configuring it at system level, use the tool Add a New IP Address. You don’t need this if you already changed the IP at system level or you use NAT.

Next, go to Server Configuration, Basic WebHost Manager® Setup and put the new main IP in:
The IPv4 address (only one address) to use to set up shared IPv4 virtual hosts

You need to change make WHM know that here was changes in the list of IP addresses. For that, use the option Rebuild the IP Address Pool.

Then go to Resellers, Manage Reseller’s Shared IP and if you have a reseller – change the main shared IP for each.

After that you will be able to set the new IP for a single (Change a Site’s IP Address) or multiple accounts (Change Multiple Sites’ IP Addresses).

To check that the operations you just did was applied, use the option Edit DNS Zone.

This should be enough.