How To Move A WordPress Site To New Hosting

Last week I had to move several of the websites I look after to new hosts.  It was a task I was dreading, but with some research and a bit of trial and error I managed to slim down the procedure to a set of managable steps.

After reading about the different WordPress plugins which would help me achieve a smooth move, I chose to use the Duplicator plugin. It had many good reviews and, importantly for me, it is free.

I had cPanel access to both the source and destination hosting accounts, so was able to set things up there without having to ask technical support for help.

Seamless vs Jerky Website Transfer

First an important note:  It’s much easier to do the website move if you can change the nameservers to point to the new hosts nameservers.  This does mean a small amount of site downtime, but if this is acceptable, then it’s far easier.

However, in some cases that’s undesirable.  You may need to install your site on your new hosting then swap over the nameservers once you’re confident that the new site is working properly. This should give no user downtime – not even a maintenance message! To do this, we will have to edit the Windows host file to access the site on the new hosting.  If you’re on a Mac, you may need to do a Google search as I don’t know how that differs.

Duplicator Tutorial Video

Here is Duplicator’s tutorial on moving sites. This latest version was made in January 2014 but is still current.  However, my way seems (to me at least) to be less complex.

Step By Step Instructions to Move A Website

So without further ado, here is the method:

1. Install the Duplicator plugin on the domain to be moved.

2. Follow the instructions to create the package of installer and archive file and download them to your computer.

3. Optionally, log into the control panel. Make a note of the email addresses which have been set up as these will have to be manually reinstated on the new host. Also, note any email forwarding settings as they will also need recreating.

4. If an Addon domain is required, set that up now. If you don’t know what an Addon domain is, then no worries, you won’t need one.

5. There are 2 ways of doing this next step. a) easy or b) techie
a) The easy way: Install WordPress on your new host. Use whatever auto installer is supplied with your host’s version cPanel. Make sure that you install it into the root of the domain you’re moving to not the wp directory.  Once it’s installed, go into the cPanel’s File Manager and download wpconfig.php to your local computer.

b) The techie way:  In the cPanel of the new host, create a MySQL database by finding the MSQL databases icon in the control panel. Go into that section. Type in a new database name and click createDatabase. Once it pops up the confirmation page, copy the line “Added database <<databasename>>” and paste it into a text file. Go back.  Now we need to create a user so find the appropriate section and type in a username. I usually have the same name as the database unless it’s too long in which case anything is fine,  Copy and paste the username into a text doc and also type the password in, we’ll need those later when we run the duplicator installer.   Now add the user to the database.  On the confirmation screen, I check the all privileges box then click “Make Changes”.  That’s that section complete so return to the main cPanel page.

6. Use cPanel’s FileManager to Upload the installer.php file and the archive zip file (which you downloaded in step 1) into the root directory for the domain on the new hosting. If you’re not using an Addon domain, then it’ll almost certainly be the public_html directory.  The duplicator written instructions say to put the files in their own sub-directory, but that just hasn’t worked for me.

7. Now we’ll need to browse to the installer.php file in the address bar of our browser.  Eg http://mysite.com/installer.php

This can be easier said than done.

  • If the name servers are already set up to point at the new site, then we can just type the address in the address bar and that should work fine.
  • If the old site isn’t being taken down yet, then we may need to edit the hosts file in the windows\system32\drivers\etc directory.  Start notepad by finding notepad.exe, right click on it and open it with admin permissions. Otherwise you won’t be able to edit the hosts file.  Browse to the hosts file to open it.  Add the line:
    123.123.123.123 domain.com
    substituting the IP address of the site – your new host should have sent you this in your welcome email.
  • If it’s an Addon domain then it might be hard to browse to unless the nameservers have already been set.  If not set, then we’re going to have to use a path from the parent domain. In this case we might need to put a .htaccess file in the root of the addon domain. Otherwise the .htaccess file from the parent domain will control the read/write permissions and stop us from seeing the installer.php file – let alone executing it.

Make sure that you’re using the whole pathname including all .com extensions like this  http://principlesite.com/mynewsite.com/installer.php

I had a real problem with this and it was a couple of hours of hard research before I found the answer in this conversation: https://wordpress.org/support/topic/unable-to-install-wp-in-godaddy-the-page-isnt-redirecting-properly

The salient point is this

If you are installing WP manually then you are not going to have any problems. The SimpleScripts automatic installer is blocked by the .htaccess rules in the parent folder that are inherited to all child folders of that parent folder. Another approach would be to be to create a RewriteEngine Off .htaccess file in the empty child folder. If you create a text file and add just this one line of .htaccess code to it…

RewriteEngine Off

…then upload the text file to the child folder and rename it to .htaccess this prevents the parent .htaccess file rules from being applied to that child folder because the child folder has it’s own .htaccess file that turns off all rewriting. 😉

8. Once you have managed to browse to the installer.php file, then it’ll run on it’s own.  Follow the instructions.

Wordpress Duplicator plugin - deployment screen
duplicator installer screen

If in step 5 you picked option a) Install WordPress, then select the bottom radio button “Connect and remove all data”. Then open the wp-config.php file you downloaded and look for the section which looks similar to this

// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘donnamic_wp11’);

/** MySQL database username */
define(‘DB_USER’, ‘donnamic_wp11’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘S!92)QP8oS’);

Paste the DB_NAME value into the name field
Paste the DB_USER value into the User field
And the DB_PASSWORD value into the password field.
Then test the connection, it should pass.

You will also need to use cPanel’s Filemanager to rename the wp-config.php (I change it to wp-config.php-old) before proceeding with the install.

If you picked option b) paste in the database name, username and password we saved in the text file earlier. Leave the top radio button “Create New Database” selected. Test the connection then proceed with the installation.

9. I had one instance where I was unable to get into the admin section of the new WordPress site after doing the move, so for that reason now I always choose to create a new admin user with a non-preexisting name just to be on the safe side.

10. Go through the installer and then when it gets to the end, log into  the site using the URLl like this

http://mynewsite.com/wp-admin

unless it’s an Addon domain in which case it’s

http://principlesite.com/mynewsite.com//wp-admin

11. Allow the duplicator to do it’s cleanup by clicking the appropriate warning messages.   Go into the permalinks and save changes (even if no changes have been made) This will update the .htaccess file correctly. Then visit the site.  If everything is fine, proceed.

If you want the site to be www.sitename.com you’ll probably need to change that in the general settings.

12 Back in the cPanel, go into the file manager and delete the zip file which you uploaded earlier. For some reason, the duplicator’s cleanup routine doesn’t delete it.

13. It everything’s working fine, skip to setup 12.  If it’s not quite working correctly, you may need to check the site name has been set up correctly in the database.  So in the cPanel go into phpMyAdmin, select the database from the list on the left and find the table wp-options
Check that the siteURL is correct if not, edit it to be correct.  It might be wrong if you’re using a temp URL or an addon domain while running the installer.php

14. Make sure the email addresses and the forwarders are set up.

15. Go into your domain registrar account and change the nameservers over.

16. After a couple of hours (or overnight), check all is well.

17. As a belt and braces precaution, I leave the old site on the original host for a week before I delete the site from the original host.  That way if there are any issues I can roll back by changing the nameservers.

Troubleshooting:

On Hostgator:

Problem: When clicking home after going to an internal page the URL in the address bar featured the principle domain as well as the Addon domain.
Solution: Go into phpMyAdmin, find the wp_options table in the relevant database and in the ‘option_name’ field find the row with the value ‘home’ editing the option_value field to be the same as the siteURL.  This should fix the problem but may then lead to problem B.

Problem: On HostGator and HostPapa we had a problem whereby trying to access an internal page gave an Internal Server Error 500.

found the answer here: https://wordpress.org/support/topic/internal-server-error-with-wp-on-an-addon-domain

The salient point is this:

However, I thought the problem might be with the .htaccess file so I played around with that a bit and discovered the solution. In the .htaccess file, there are these 2 lines (among others)…

RewriteBase /addon/
and
RewriteRule . /addon/index.php [L]

and I manually changed them to:

RewriteBase /
and
RewriteRule . /index.php [L]

and that solved the problem! All the links are going where they should now, and I’m not getting the internal server errors anymore.

And that worked for me too.

If this guide is helpful, please let me know in the comments below.