Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dbushell
Last active November 23, 2015 10:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbushell/403bd7bdf3072392ba86 to your computer and use it in GitHub Desktop.
Save dbushell/403bd7bdf3072392ba86 to your computer and use it in GitHub Desktop.
WordPress local development (MAMP)
Easy steps for cloning a live WordPress site for local development with MAMP. Am I missing anything?
1. add new MAMP server
2. download all files
3. export MySQL database
4. import SQL to MAMP via command line:
/Applications/MAMP/Library/bin/mysql --host=localhost -uroot -p dbname < ~/Downloads/database.sql
5. update: wp-config.php
define('DB_NAME', 'dbname');
define('DB_USER', 'root');
define('DB_PASSWORD', '[PASSWORD]');
define('DB_HOST', 'localhost');
define('WP_SITEURL', 'http://localhost.dev');
define('WP_HOME','http://localhost.dev');
6. done?
@saltandvinegarcrisps
Copy link

Maybe add these to your config for dev?

define('WP_DEBUG', true);
define('WP_LOCAL_DEV', WP_DEBUG);
define('WP_DEBUG_LOG', WP_DEBUG);
define('WP_DEBUG_DISPLAY', WP_DEBUG);
define('SCRIPT_DEBUG', WP_DEBUG);
define('SAVEQUERIES', WP_DEBUG);
define('CONCATENATE_SCRIPTS', false);
define('COMPRESS_SCRIPTS', false);
define('COMPRESS_CSS', false);
define('WP_CACHE', false);

@tobaco
Copy link

tobaco commented Nov 23, 2015

4.1 Search and replace server domain with local. Use: https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

5.1 Set up multi environment. Use: https://github.com/studio24/wordpress-multi-env-config

@maxkandler
Copy link

Like @tobaco I also do a search-and-replace on the database to make sure all URLs in the database are properly updated. I prefer to use wp-cli though, instead of a wp plugin.

That being said, wp-cli offers quite a few more helpful tools, e.g. wp db import will automatically take the connection data from the wp-config.php to import the SQL file, making step 4 a bit easier.

@tobaco
Copy link

tobaco commented Nov 23, 2015

@mkleucker it's not a plugin. it's a standalone script with some nice features like „dry run“ (preview of what will be replaced and where)

@maxkandler
Copy link

@tobaco Ouch, sorry. I confused it with https://wordpress.org/plugins/better-search-replace/ just by the title.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment