When you need to move WordPress to a new host or domain it can be a frustrating experience. In theory it should be easy to execute the transfer – just copy the files and database to the new server right? Unfortunately this it isn’t that easy with WordPress.
The WordPress database contains hard-coded references to the existing site URLs that can be encoded in such a way that a simple find and replace won’t work. In fact many of the tutorials you find online are flat out won’t work completely.
Although you can manually move your site, it’s usually much easier to use a plugin to do the job. What follows is a description of how to use the Duplicator Pro plugin to migrate a WordPress site to a new domain or host.
Very Large Sites: If moving a very large site see How To Move A Very Large Site after reading this article.
Live Site Overwrites: When installing over an existing live site read How To Replace a Live Site after reading this article.
Site Move Overview
Let’s start by looking at an overview of the migration process. A detailed description of each step will be described in the next section.
Create a ‘Package’ of Your Site
Duplicator Pro works by bundling up your site the following two ‘package files’:
- Installer.php: Used to install the site. Simply browse to installer.php to start the installa wizard (described later).
- Archive.zip: Contains all site information – both standard site files as well as a dump of your database.
- Note: A backup of the installer.php file is also contained within the archive file
Move the Package to the New Site
Now it’s a matter of copying the package files to the new location. You can do this by simply downloading the files or create a storage location such as Google Drive and Dropbox. Once the files have upload to say Google Drive you’ll have the same files on your local computer via Google Drive Sync.
Browse to the Installer
Once the package files are at the new location, browse to the http://yoursite/installer.php and follow the instructions shown in the wizard. The installer will extract the site files from the zip archive, install the database and replace site URLs with new ones.
Detailed Move Steps
The specific steps used to move WordPress using Duplicator Pro are as follows:
1. Package: Step 1 – Setup
One can create a package in a couple different ways, but for the purposes of this article let’s keep things simple and create a package manually vs. using a schedule.
a) Go to WP-Admin > Duplicator Pro > Packages screen
b) Click the “Create New” button
This will take you to the “Step 1: Package Setup” screen which has the following options:
- Name: File name the package will be stored under.
- Storage: A list of storage endpoints such as local server, FTP server, Google Drive or Dropbox
- Archive Files: Allows you to specify which files/directories to included in the archive.
- Archive Database: Allows you to specify which database tables to included in the archive.
- Installer Presets: Set default values that are populated in the installer at install time, these values are optional.
In this example we’re only going to choose the “Default” storage location. This location is set to the /wp-content/backups-dup-pro directory. When packages are stored in this location they’ll be very easy to download, as we’ll see later.
After you set the appropriate parameters, click the “Next” button.
2. Package: Step 2 – Scan
At this point your site will be scanned based on the parameters you had entered. The scan step looks through your entire file system, checks the sizes and determines if various system parameters look good for package creation. You may have warnings this screen. In our example you can see that we have gotten a clean bill of health so we’re good to go. Click “Build” to continue.
Warnings Warnings advise you of something that may cause a problem, although many times they can be safely ignored.
3. Package: Step 3 – Build
At this point you’ll be returned to the package list and will see an indication that a package is being built. The amount of time to build a package depends on the size of your site and the speed of your host. Smaller sites or sites on a VPS/dedicated host can take a handful of seconds, while larger sites using shared budget hosting can take several minutes.
4. Transfer Package Files to Destination Server
The new package will be displayed in the list after it has been built. Because we chose the default storage location, the “Installer” and “Archive” buttons will be enabled which allow us to download these files directly from this page.
a) Save to your local computer. Click on each of these buttons in turn and save the corresponding file to your local drive. If you are installing to your local development machine save or move these files to the appropriate local location.
b) Upload to your server. If you wish to install on a server on the Internet, then upload the saved package files to the destination server. You can easily do this with a free FTP client like Filezilla or do so using a file-manager your host has provided, such as cPanel.
Put the package files in one of the following locations depending on where website files reside for the site you are installing:
/public_html/[site package files here]
/public_html/my_addon_domain/[site package files here]
/public_html/my_subdirectory/[site package files here]
*This location may be different on your host. If you aren’t sure where website files should reside contact your web host support desk.
5. Create Database and User
If you are overwriting an existing site you can skip this step.
Before we try and install our new site we need to make sure we have a database that WordPress can use. If we don’t already have one to connect to, then we can easily create one by following the directions below.
a) Login to server control panel. Login to your cPanel or other control panel your host has provided.
b) Start database management. Click on the mySQL databases icon or equivalent.
c) Create database. Give you database a name then click “Create Database”
d) Create a new user. If there isn’t one already in one in the user drop-down and click “Add”
e) Set user privileges. Click on User > Check “All Privileges” check-box > Click “Make Changes”
6. Edit Development Machine’s Hosts File
This step only applies when moving hosts while keeping the same domain (abc.com on host1 -> abc.com on host2)
If you’re copying a site to a different domain or path or to/from localhost then skip this step.
The hosts file maps a host name to an IP address. This allows you to override which server is hit when you browse to a site. What we want to do is trick our development machine (machine running the browser) into thinking the domain resides on your new server before the DNS has switched.
This is important because it allows us do the real domain switch only after the install and things have been confirmed working – allowing us to avoid any downtime.
Step 6.1 Determine the IP address of the new server
Login into your host to see what the IP address of your new server is. You’ll be able to determine this directly or may need to talk with your host support.
Step 6.2 Load your development machine’s host file
Now we’re going to want to bring your local development machine’s host file. Please see this article on how to edit the hosts file on your particular operating system.
Step 6.3 Change the hosts file
Go to the bottom of the hosts file and enter something a line in the form “the_ip_address your_domain_name”.
For instance, if my new server’s IP was 220.127.116.11 with domain name mydomain.com, I would add
Step 6.4 Flush DNS on your local machine
After you’ve edited your hosts file you’ll have to flush the DNS on your machine. This is required to ensure that your development machine serves up the correct IP when asked since the old name to IP mapping may be cached.
Open an command window with administrator privileges and enter the following:
Mac OS X
7. Kick Off the Installation Wizard
Finally, we can install to the site using the installation wizard.
a) Browse to the installer. browse to the installer on your site (http://yoursitename.com/installer.php) to start the installation process.
b) Choose database type. Choose if you are creating a new or connecting and removing data from an existing database. In most circumstances you will choose the second option since you are installing to an already created database (creating a new database only works when you install to localhost).
c) Fill in database information. Fill in the necessary information to connect to the database. Note: If you are overwriting an existing site, you will be asked if you want to reuse the database credentials from the existing site. Keep in mind that database will be erased.
d) Select advanced options. There are additional advanced options which we won’t cover in-depth here, but they involve things like manual extraction of the archive which comes in handy if your server has a hard time processing larger packages with the installer and many others.
e) Click “Run Deployment”. Click the “Run Deployment” button to kick off the installation process.
f) Review the second install screen and finish the install. After a period of time a second screen pops up which informs you about which URL and path information is being swapped out. Once you are satisfied you may continue and finish the install.
8. Change domain servers
If you moved a domain between hosts you may now switch the name servers to the new host and remove the entry made in the hosts file in step 6.
It can be Easy to Move a WordPress Site
As you see from the above, migrating WordPress doesn’t have to be a painful or complex process as long as you have the right tool. WordPress site owners can feel trapped on a bad host or domain but it doesn’t have to be that way. As you can see from the above steps, you can unlock your site or business quite easily and move WordPress wherever you want.