Digital Development
Web Design

I was recently asked to restyle a Wordpress site for a client and found its not so straightforward to set up a development version of a live site on your localhost, in my case using MAMP. There's a Wordpress article which addresses the topic but its kinda useless given all the necessary steps aren't described and, as often occuring with such issues that are seemingly trivial, you'll find all kinds of conflicting solutions if you try to search for the best steps. Here's what worked for me and what I can recommend will help you out should you come across the same problem:

  • Download all Wordpress files from the live site to your root directory on localhost.
  • Enter the live site's PHPMyAdmin and export the database. This will give you a MySQLdump file.
  • Open the newly created MySQLdump file and replace all instances of the live site's url to your new file path on your localhost, e.g. "localhost:8888/[directory name]", ensuring your localhost port is set accordingly in your MAMP preferences.
  • Create a new database on your localhost with the same name as live site's database, setting the username and password, e.g. "root" and "root", and import the MySQLdump file edited in the previous step. You can perform this import using the following command in Terminal (command line):$ mysql -u username -p -h localhost database-name < mysqldumpfilename.sql
  • Open the Wordpress wp-config file and change all instances of the live site's url to "localhost:8888/[directory name]".
  • Run the following command in MySQL.
SELECT * FROM wp_options WHERE option_name = "home" OR option_name = "siteurl";
UPDATE wp_options SET option_value = "localhost:8888/[directory name]" WHERE option_name = "home" OR option_name = "siteurl";
  • Open the Wordpress admin page through your browser and set all permalinks to "ugly" to enable all site links on your localhost.
  • Sit back and do some great coding on your local server while the live site stays live!