Here’s a question I saw today: how do I move my WordPress site to a new server?
This can be a fiddly exercise with a number of steps to go through, and you should avoid it if you possibly can. However, on the basis that you can’t avoid it, here’s the answer.
Note that the process I’ve set out below assumes that you’re using the same domain and that you (or someone) have set up the servers correctly.
Process for moving WordPress to a new server
Step 1 – Back up WordPress
Make a full back up of your current WordPress site – database and system files.
I wrote an article with full details and options on how to back up a WordPress site here.
Step 2 – Install WordPress on the new server
If you’re not using BackupBuddy (that I referred to in the article above) you will either need to FTP your previously backed up WordPress files to your new server or install a new version of WordPress (probably the easier option).
Uploading your previously backed up WordPress files
If you’re going to upload your backed up files you’ll first need to establish a database, which you can do through the MySQL Databases link in your control panel.
When you’re importing a database you’re actually importing the tables – i.e. the database content. So you need to establish the database first – think of it as the ‘container’ – into which you can then import the tables.
When you’re setting up your new database you’ll need to use the same database name, username and password details that are specified in your backed-up wp-config file.
After downloading your WordPress files, open wp-config in a text editor to get the details.
Alternatively, you could set up new database details, but then you’ll need to change the details in your backed-up wp-config file to match them.
This will ensure that WordPress and your database are able to establish contact with each other, and you must do this before uploading your WordPress files.
Once you’ve uploaded your WordPress files you’ll need to follow the instructions here (step 6 of the Famous 5-Minute Install) to complete the installation of your backed up WordPress files.
If you get an error it will probably be because the
install.php file is missing.
In this case, download a copy of WordPress from WordPress.org, locate the
install.php file (in the
wp-admin folder) and upload it to the
wp-admin folder on your server.
Then repeat step 6 of the 5-Minute Install.
Completing step 6 (of the install) will establish the connection to the database you’ve set up and leave you with an empty version of WordPress (no posts), but with all your plugins and themes in place.
Installing a clean version of WordPress (the easier option)
Alternatively, you can install a clean version of WordPress.
Both the processes I’ve described above (installing new or installing from back-up) will ensure your database is correctly set up and linked to your WordPress files.
After you’ve installed a new version of WordPress you may want to FTP your ‘old’ wp-content folder to your server to replace the one that has just been installed.
This will ensure the plugins and themes you had running on your old (current) site are available in your new installation.
Step 3 – Import the database
Once WordPress is correctly installed on your new server you’ll then need to import the tables of the database that you backed up earlier.
Import using WP-DBManager
As I mentioned in the earlier article, I recommend using WP-DBManager because this will import a previously backed up database and it works well.
Other database backup plugins will also import databases but I’ve only used WP-DBManager, so I can only vouch for that one.
If you don’t already have WP-DBManager installed and activated, do so now.
Then FTP your backed-up database to the wp-content/backup-db folder on your server.
Next, navigate to the Database>Manage Backup DB screen in your WordPress admin area and select the database to restore (it will probably be the only one there, but choose the most recent one if it’s not).
The plugin will do its stuff and your database will be restored (imported).
You can also use PHPMyAdmin (which you can access via an icon in your hosting provider’s control panel) to import a database.
Here are two videos that describe in detail how to import databases into WordPress using PHPMyAdmin:
Note: When these pages load you’ll see that the title of the first video says ‘alternative to PHPMyAdmin’. In fact, only the second video (dealing with large databases) introduces the alternative. Both focus on PHPMyAdmin as the basis for doing the import.
Both videos are extremely thorough and describe how to import small databases as well as databases that exceed the import limit imposed by many hosting providers.
Step 4 – check your site
Once your database has been successfully imported you will need to check your site to reactivate all your plugins and check that your widgets and everything else is in place.
Once that’s completed you’re all done for the manual process.
An easier (and more automated) process
A far easier (and less stressful) way to move WordPress would be to use BackupBuddy, which I referred to in the article at the beginning.
Assuming you already have BackupBuddy installed, here’s the process:
Step 1 – Backup your site
Using BackupBuddy, create a full backup of your WordPress site (database and files) and download the backup file to your machine.
You’ll probably need to FTP this because many email providers place a limit on the size of a file that can be accepted as an attachment. However, for small files (sites) the email option is there.
Make sure you’ve downloaded the
importbuddy.php file to your machine as well.
This can be downloaded by clicking the link in your BackupBuddy screens and saving the file on your machine:
Step 2 – Import your site to the new server
Upload both the newly-created backup file and the
importbuddy.php file to your new server, so that they are accessible from the Internet.
Using your web browser, navigate to
importbuddy.php on your new server – e.g.
www.yournewserver.com/importbuddy.php – and follow the on-screen instructions.
Be sure to have your database details to hand (database name, username and password).
BackupBuddy will establish your database, install WordPress and import all your posts, pages and other data in your database. You don’t need to do a thing.
One important thing to be aware of:
If you’re migrating your site from one hosting provider to another there is always the risk of problems occurring because servers can be set up in so many different ways.
While BackupBuddy does have filters built in to take account of different server configurations, it cannot guarantee to have all configs covered.
It would be prudent, therefore, to assume that the servers on your new hosting provider are set up differently from the servers on your current hosting provider – and to be prepared for problems.
If you’re migrating to a different server with the same hosting provider compatibility problems should not occur.
But in this case it would be better to get your hosting provider to do the migration!