Migrating A WordPress Site – Step By Step
These instructions are for sites that run Apache servers, either on Linux or XAMPP. They may work with others, but have not been tested.
Whenever I develop a new site, or need to make extensive changes to an existing site, I like to do the work on a local install and then migrate the site to the live one. This is a description of the process I use. As of this writing, this has been used on WP versions 3.1 through 3.9.1.
Note that if you are changing a live site, it should be ‘frozen’ so no changes can occur to it while you are working on the modifications. One way to do this is to install a ‘maintenance mode’ plugin that will let viewers know that the site is being modified.
I use two plugins to help in the process:
A. The first set of tasks is to prepare the ‘New’ site:
- Create a database and install WP on the New site.If I am trying to set up a local site from an on-line site, I use xampp on my pc and I try to name the database and site the same as the live site, but this is not strictly necessary. In any case, install WP in the new site whether local or on-line.
- Install and activate both plugins.
- Open WP Migrate DB from the Tools menu, but only to get the values for ‘Current address (URL)’ and ‘Current file path’. Save these values for later use.
B. Next, get the data from the ‘Old’ (existing) site:
- Install and activate both plugins. Configure BackUpWordPress as you like.
- For safety’s sake, run BackUpWordPress from the Tools menu and download the zip file to your computer. This is a backup of the unchanged site for emergencies, so be sure to include the database in this backup.
- Update WP and all plugins to the latest working version. This step is not absolutely necessary, but this is a good time to get everything current.
- Update July, 2014. Some security plugins and cache plugins have been found to interfere with later steps, so it is a good idea to deactivate them now.
- Run BackUpWordPress again and download the zip file to your computer. It is not necessary to back up the database during this step.
- Run WP Migrate DB from the Tools menu. Use the values you saved in step A-3 above for ‘New address (URL)’ and ‘New file path’. Save the output file to your computer.
C. Now load the data into the New site:
- Unzip the Old site backup file that was created in Step B5.
- Edit wp-config.php and change the ‘DB_NAME’, ‘DB_USER’, ‘DB_PASSWORD’, and ‘DB_HOST’ to the values for the New site. You can get these values from the wp-config.php file of the New site before you upload the Old site data.
- Note that the .htaccess file can contain rules that reference the Old site. Any such references must either be removed or rewritten to reflect the New site. One approach is to save a copy of the file from the Old site and then delete it from the upload. Then add parts back in as needed.It is safe to remove lines between ‘# BEGIN WordPress’ and ‘# END WordPress’ because WP will recreate these lines, although you may have to assign Permalinks back to default and then back to the current assignment to trigger this.
- Use ftp to copy the files to the New site, overwriting the initial installation. If the WP version is the same for both sites, you can delete the wp-admin and wp-include folders from the backup to shorten the upload time. I always leave them in in case I overlooked an update.
- Use phpMyAdmin to import the database contents file produced by WP Migrate DB.
- If you have access errors, try going to Admin->Settings->Permalinks and just clicking ‘Save Changes’. No need to actually change anything. If you still have problems, check that you used the correct URLs when you exported the database.
- Reactivate any plugins that you deactivated in Step B4.
If Lady Luck is smiling, you should now have an operating copy of the site! Your login credentials should be the same as on the Old site.