WordPress currently holds more than 54% of the Content Management System (CMS) market
, and powers a staggering 73,000,000+ sites.
If you are a web developer, the chances are excellent that you will be asked to work on the WordPress platform at some time in the future if you are not currently working on it already.
With that kind of market share, you would think that the core developers would have made migration of a WordPress site from one domain name to another a simple, one-click operation. Unfortunately, this isn't the case so it has fallen to the community to create solutions for moving a WordPress site from one place to another.
This is a common task for WordPress developers. I typically begin working on a new site on my local machine running WAMP
so the site is accessible at http://localhost/sitename
. However, the end result has to be http://www.clientdomain.com
and getting from the development server to the production server requires some knowledge or willingness to spend a little money. This article will present two generic methods to move a site...one free and one that requires the use of a paid plugin.
When moving a WordPress website from one place to another, you are really talking about transferring three things:
1) The site's theme
All three items above exist as both separate files within the WordPress file system and also as a collection of entries in the MySQL tables that are the other half of a WordPress installation. Therefore, moving a site requires us to move some files and export/import the database tables.
Moving a WordPress Site Without Spending Money
Step 1: Exporting the Database
The MySQL database that runs on the back end of every WordPress site is the most important thing to move properly and also the hardest thing to move properly. Care must be taken to not only ensure the data is not corrupted but also that all settings are preserved and properly changed in order to make the new site work.
The easiest way to move a WordPress database is to simply do a SQL dump on the existing database to get a text file in return. Assuming you are using the popular phpMyAdmin
tool to manage your MySQL data, simply navigate to the database in question and click the Export tab and select SQL from the export options and "Save As File".
If you are using a newer version of phpMyAdmin then your Export screen may look like the below:
which is even easier.
If you don't have phpMyAdmin or want to know the MySQL command to export all tables in a database to a dump file, you use the mysqldump
utility from the MySQL command line:
mysqldump mywordpressdb > mywordpressdb.txt
No matter which method above you use, the result should be a plain text file of your current WordPress data, settings, and content in SQL format. Make a copy of this file and keep the original somewhere safe just in case we need to start over.
Step 2: Changing the URLs and Paths
Open the copy of the SQL file in a good text editor like Programmer's Notepad
and do a search and replace on "oldurl.com" changing it to "newurl.com" This will fix any settings or hardcoded links that reference the domain name. You will also want to do a search and replace for "/old/wordpress/server/pat
h" and changing it to "/new/server/wordpress/pat
h" . This step is necessary for some themes and plugins that store preferences using the server path and not the URL.
Once you have made those changes, save the file and import it via phpMyAdmin (or your preferred method) on the new server to recreate the WordPress tables.
If you are hardcore (or if the export is too big to open in a text editor) and want to change domains and paths with SQL, do the following commands on the new server after importing the tables (and skipping the text editor step):
Code above taken from http://www.billerickson.net/how-to-move-your-wordpress-website/
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldsite.com', 'http://www.newsite.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldsite.com','http://www.newsite.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldsite.com', 'http://www.newsite.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.oldsite.com', 'http://www.newsite.com');
The WordPress Codex
recommends not doing a simple search and replace due to serialization needs for some plugins or theme files. I personally have not
encountered any problems using either of the above methods and the Codex is not always 100% correct for modern versions of WordPress. But if you are concerned then you can limit the search and replace to the wp_posts table or use the recommended search and replace script
to make the changes safely.
Step 3: Move the relevant files.
We are assuming that a new, blank copy of WordPress is installed and pointing to the new database location. If so, you are now ready to move your theme, plugin, and uploads. Simply FTP to the old site and download the wp-content folder in its entirety. Then FTP to the new site and upload that same wp-content folder to the new site. wp-content contains all themes, plugin files, and images. At this point, the content portion of the site transfer is complete and you should be able to see a reasonably complete and working site in the new location.
Step 4: Test and Clean Up
Access the Dashboard of the new site now and make sure you can login with the Administrator account. If you can't, check your wp-config.php file and make sure the MySQL server details are correct. Also check to see if there is a randomly-generated table prefix applied to the tables and, if so, make sure your imported tables have that same prefix. If the imported tables have a different prefix, change this setting in wp-config.php.
Once you can access the Dashboard and your site's content is visible, start navigating like a typical user. If you have trouble navigating (i.e. you are getting 404 errors) then go to the WordPress Dashboard and select Settings | Permalinks. From here, change the permalinks to Default, then save, then test. If that restores navigation, then go back to the Permalinks settings and change it back to your preferred settings. Changing the permalinks tweaks the .htaccess file which controls WordPress and is critical to a working copy of WordPress. Test all plugins for functionality and if any appear to be broken, deactivate and reactivate or (better yet) delete and reinstall the plugin. Deactivation/reinstallatio
n resets any entries in the database or recreates any special code needed by that particular plugin. Finally, make sure any services that know your site by the old address are updated to the new address. This includes things like Akismet, Jetpack, WangGuard, VaultPress, etc.
Moving a WordPress Site Faster and Easier By Spending Money
Do you have trouble spelling MySQL, PHP, and FTP? Does looking at a command prompt give you the willies? If so, then perhaps the above section is not for you. Instead, you want the simple, one-click solution alluded to in the opening section. It does exist, but as a premium plugin called BackupBuddy
BackupBuddy is a plugin that automates WordPress backups and allows you to not only backup the database but it can also backup a complete WordPress installation, including the core files. You will be given the option to migrate to a new domain name during the restore function, making BackupBuddy a complete and easy migration solution.
The complete steps are:
1) Make a full backup of the old site using BackupBuddy
2) Set a password on the backup
3) Move the resulting backup file and the generated ImportBuddy PHP script to the empty folder on the new server (do NOT install WordPress on the new site)
4) Run the ImportBuddy script and choose “Migrating” when prompted and follow the prompts from there.
After following the above steps, your entire WordPress site, media, themes, plugins, and content will be restored under the new domain name and be ready to use. That's it.
At the time of this writing, you can obtain a two-site license for $75 or unlimited sites for $150. If you find yourself moving a high number of sites, it's well worth the money for the time-savings provided to say nothing of the excellent backup capabilities it gives you.
That's All, Folks.
This guide was heavily influenced by Bill Erickson's most excellent version at http://www.billerickson.net/how-to-move-your-wordpress-website/
and the WordPress Codex entry: http://codex.wordpress.org/Moving_WordPress
as well as my own experiences. If you have any questions, found it helpful, or just wish to share your experience in moving a WordPress site, please feel free to add them below. If you are an Experts Exchange member, please click the “Yes” link to vote this article helpful.