How to mirror WordPress development environment and live site?

1.2k views Asked by At

What's the best way to mirror, when you have a development environment and a live environment with WordPress (including two different URL's).

Is it simply by making a backup of one environment (FTP->Data, SQL->Database) and setting it up on the other environment?

2

There are 2 answers

0
FluffyKitten On BEST ANSWER

The easiest way to make a copy of a Wordpress site is to use a plugin like Duplicator. It handles everything from copying the files to updating the WP database with the new domain etc.

  1. Install the plugin on the website you want to copy (i.e. your development environment)
  2. Build the package - this creates a single archive file with the site database and files. Depending on your hosting settings you might get timeout errors when building the package. In that case I exclude the uploads folder and then copy it across manually
  3. Copy the archive & installer to the destination environment
  4. Create an empty database for your new site
  5. Run the installer.php that you uploaded to the destination. It will guide you through entering the new database and domain details

And that should be it! You might need to save your permalinks or make some other tweaks depending on your own setup, but its usually that simple.

0
Juan On

For the general case it is not that simple.

What you mention can be done for example if you download everything to your local environment and in your local environment you change the hosts file for 127.0.0.1 to be the real FQDN of the site for example www.mysite.com. And you also setup your local virtual server to host that domain.

Otherwise you have to follow a series of steps which involve changing data in the database that references the FQDN, mainly in POSTs and PAGES, but could also be in OPTIONS. Check the Wordpress CODEX for detailed instructions.