Setting up a development instance of WordPress from a production site

If you ever want to copy a version of WordPress from a production site, then you need to make a few configuration changes in order that you can get it working locally. I always run on XAMPP locally as I find it works really well and is reliable (I am on a Mac).

Here is my simple step by step guide to doing the setup:

  1. Take a copy of all of the files from the production server
  2. Place these files within a folder under your local document root on your local install of XAMMP
  3. Take an extract of the database using phpmyadmin. I find just an extract that produces a set of SQL statements works well enough for small databases
  4. Create a new database locally and import the extract into this database using phpmyadmin
  5. Create a user with a password (ideally the same as setup in production) and give this user privileges to access your new database
  6. In the database, you need to make the following changes:
    1. Update the wp-config table where the option name equals to home and siteurl to the URL of the local site  (otherwise all links will take you back to the production site)
  7. If required, edit the wp-config.php file within your local copy of the files and ensure the database host name and username / password are setup correctly for you to run locally. I find for my Mac that localhost does not work and that you need to enter the value of 127.0.0.1 instead

Two final points:

  • I found that all of the above worked OK until I started clicking on links generated by wordpress. I then got an object not found error message from WordPress. To get around this, I found that if you go into the administrator site of WordPress and under Settings -> Permalinks you updated this then it sorted itself out. Even if you update it and then put it back to what it was originally it still seemed to sort out the problem
  • I found that when I tried to upload themes it kept asking me to login to the FTP server. This is a pain and not possible on my local Mac. The issue here is that WordPress is running on XAMPP which is run by a nobody username. Therefore, it find it cannot access any of the folders that it sits on. To get around this, you need to change XAMPP to run from your username and then it will allow you to access your own file system from WordPress. See below for the changes

In the file /Applications/xamppfiles/etc/httpd.conf, change the user and group from

User nobody

Group nogroup

to

User <your local Mac user name>
Group staff

Hopefully that all works and gives you an idea of how to do this.

Leave a Reply

Your email address will not be published. Required fields are marked *