I was recently in a situation where I needed to change my hosting company with whom I'd been with for several years and had consequently built up several WordPress websites which needed moving.
Having spent quite some time weighing up the pros and cons of various alternative hosting companies, I finally decided upon one that I liked the look of and based my choice on reputation, customer ratings as well as cost.
I decided to write this article, to help you do the same thing should you need to, and that is to answer my burning question: how to move a WordPress site to a new host?
I don't want to bore you with all the reasons why I wanted to change my web hosting, suffice it to say it had a lot to do with the ridiculous amount it would cost me to renew my existing contract!
Now, if like I was, you are currently using a very well known hosting company that has cPanel as the interface to maintaining your websites, then I hope this article will be of great interest.
The company I decided to move to also had a cPanel interface, and were offering to transfer my websites from my existing hosting server for free!
The problem however, was that they were going to do that by utilising cPanel's backup and restore facility which would have meant cloning the entire content of my existing cPanel structure.
This was not what I wanted though, since I only wanted some of my Add-On domain websites transferred and the Primary domain I wanted to host separately on my Wealthy Affiliate hosting account.
Moving Add-On domain websites
This left me with the problem of how to move only the websites I wanted to host with the new company and which were Add-On domains; so I started researching the best way to do this.
I found several possible methods of achieving my objective, most of which included using various WordPress plugins, but this would involve temporarily installing an additional plugin on my sites, which I didn't particularly want to do.
I also found a method which gave me more control over what I was doing and would keep my WordPress sites exactly as they were. This method used file-transfer and involved:
- Making a backup copy of each website
- Exporting a copy of each WordPress database
- Migrating the websites and databases to the new hosting server
The remainder of this article will lead you through, step-by-step, the procedure I followed. I hope you find it useful.
Backing Up Your Website Files
This is done quite simply, by using cPanel's File Manager.
- Log into cPanel
- Locate and open File Manager
- On the left hand side of the File Manager, locate and expand the public_html directory.
- Now select the directory having the domain-name of your WordPress website (Note: if your WordPress files for your website are in the public_html root directory you may be best to use the alternative method of transferring the site, described in another article).
- With the website directory open, in the right hand side of the File Manager, click on the top item in the list and then choose the Select All option from the File Manager tool bar.
- Now choose the Compress option from the File Manager tool bar, or right-click and select Compress from the pop-up menu.
- In the Compress pop-up window, select the Compression Type – (I suggest Zip Archive if you are using a Windows computer).
- Give the archive a meaningful filename, e.g. /mywebsite.zip and then click on the Compress File(s) button.
- Let the Compression tool do it's work, which will take a few minutes, depending on the size of your website.
- Go back to the File Manager listing, locate and select the compressed archive file you have just made.
- Right-click and choose the Download option from the pop-up menu, or choose the Download item from the File Manager tool bar.
- Save the archive file somewhere safe on your computer.
- Now go back to the File Manager, locate and select the wp-config.php file and Download the file to the same location you saved your website archive file.
Backing Up your Website database
To backup the WordPress database, which is essential to the functioning of a WordPress website, we are going to use cPanel's phpMyAdmin tool.
- Log in, or return to the main cPanel homepage.
- Locate and open phpMyAdmin.
- On the left hand side of the phpMyAdmin window is a list of one or more databases (depending on how many websites or other databases you currently have hosted).
- Go to and open in NotePad, the wp-config.php file you saved to your computer earlier.
- Search for the term define(‘DB_NAME' which will be followed by the name of your website's database.
- Now return to the phpMyAdmin window, locate and select the database having the same name as that in your wp-config.php file.
- All the tables in the database will now be displayed on the right hand side of the phpMyAdmin window.
- Scroll down to the very end of the Tables listing and click the Check All option. You should now see every Table in the listing will have a tick in the selection boxes to the left of the Table names.
- Now select the Export option from the Table listing tool bar.
- The Listing window will change to the Export tables window.
- Under the Export Method, select the Custom option.
- Scroll down to the Format section which should default to SQL. If it isn't, then select the SQL option.
- Scroll down the Export tables window and locate the Object Creation Options section and tick the box against the Add DROP TABLE option.
- Now scroll down to the end of the page and click on the Go button.
- You will be prompted to save the database file to your computer, which you can save to the same location as your Website archive that you saved earlier.
Migration to a Primary or Add-On domain
Before you migrate your website to the new hosting server, you need to decide if you are going to have the website domain as your cPanel primary domain, or as an Add-On domain.
The latter will need to be configured by your hosting company and you will need to ensure that the domain's DNS nameservers are changed to point to the new hosting server before you can log in to your cPanel.
There are many pros and cons to either scenario here, and will depend on how you want to organise your website directories for future development. However it is something you will need to consider before you go any further with the migration.
This tutorial assumes that you are going down the route of Add-On domains for your website migration.
Create a new Add-On domain
Before you upload any website files to your new hosting server, you will first need to create the Add-On domain:
- Log in to cPanel on your new web-host and open the Addon Domains.
- From the Addon Domains window, enter the New Domain Name you want to add, including the TDL e.g .com, .net, etc. (Note: the Subdomain entry should default to the same domain-name but without the TDL extension.)
- Make sure the the Document Root is located in the public_html directory; e.g. /public_html/mydomain.com
- Optionally select the Create FTP Account option, although you can access your website by using your main cPanel FTP account.
- Add the domain to your hosting server.
Copying your website files to your new hosting server
To copy the website files to your new web-hosting server, you now have two options:
- Use cPanel on the new host.
- Use an FTP client such as FileZilla.
Which method you use is up to you, but be aware that there is a file size limit of around 200-300Mb using File Manager (this may vary depending on your hosting account allocation), so if your website archive file is greater that that, you will need to use FTP anyway. There are ways round this limitation, but I'll not go in to that here.
For the purpose of this tutorial we're going be using cPanel's File Manager:
- Log on, or return to cPanel and open the File Manager.
- Locate and select your website domain sub-directory the public_html directory on the left hand side of the File Manager window.
- From the File Manager tool bar, choose the Upload option.
- A new Upload Files window will open, which will allow you to upload the website archive file that you downloaded from your old web host.
- Browse and navigate to where you saved your website archive (zip) file on your computer earlier.
- Return to the File Manager and select the archive file in the right hand side of the File Manager window, then choose the Extract option from the File Manager tool bar.
- After the files have been extracted, remember to select and Delete the website archive file before closing the File Manager.
You should now have all the original files for your website installed on you new hosting server, but before you do anything with the website, you will need to reinstate the WordPress database.
Migrating your WordPress database to the new hosting server
There are 3 distinct steps to migrating the WordPress database to your new web-host:
- Create a new database
- Import your websites database tables
- Connect your website to the migrated database
Below, I take you though each of these steps in turn.
Please note: If you are moving your website using exactly the same domain name, then the following procedure should work seamlessly for you; however if you are moving your website from a development server, you will need to search and replace ALL URL specific links within the database, some of which may be stored as “serialized data”. If this is the case, a standard text search & replace operation will not find the URLs within the serialized data. To get round this, consider using this utility which is specifically designed for this task: http://pixelentity.com/wordpress-search-replace-domain/
Creating a new database
- Log on to or return to the cPanel home page and open the MySQL Database Wizard tool.
- On the database wizard window, enter the name of the New Database, e.g. wrdp1, and check the name does not already exist.
- Click on the Next Step button.
- You are now prompted to create a database Username. I would suggest using the same name as that of the database, e.g. wrdp1 in our example. For the Password, you can either create a new one (but make sure you copy the password to a text file temporarily). Alternatively, you can use the password defined in your exported wp_config.php file; open the file in a text editor, search for define(‘DB_PASSWORD and copy the password defined there.
- Once created, you will be prompted to add the User to the database and you will need to assign the User's privilages. So select All Privileges, since WordPress will require full access to the database. Then click on Next Step to continue.
That's the database created – we now need to migrate our existing database tables.
Importing the website database tables
- Return to the cPanel homepage and select the phpMyAdmin tool.
- On the left hand side of the phpMyAdmin window, locate and select the database you have just created.
- From the tool bar on the right hand side, choose the Import option.
- From the File to Import window, leave all the default settings and click on the Browse button to navigate to your website database SQL file your previously exported and saved.
- Click on the Go button and wait for the database tables to import.
Connecting the website to the migrated database
We now need to connect your website to the WordPress database and we do this by editing the wp_config.php file that you saved earlier.
- Open the saved copy of the wp-config.php in a text editor and locate the following entries:
- For each definition, make sure you enter the database name, user name and password for the new database that you created earlier, and then save the file.
- Open the File Manager from the cPanel homepage, locate and select your website sub-directory from the public_html directory.
- Click on the Upload option from the File Manager tool bar.
- On the Upload Files window, check the Overwrite existing files option and then Browse to the wp-config.php file you have just edited, and upload the file.
You have now migrated your entire WordPress website from your old hosting server to your new one.
All that remains is to change your domain-name's DNS nameservers to point to your new web-host to take your website live.
I hope you have found this “how to move a WordPress site to a new host” tutorial useful and I look forward to your comments below.
You may also be interrested in this article: