Follow Brian Li (@DecryptoBL) on Twitter.
Follow Brian Li (@bwhli) on Instagram.

How to Install WordPress 4.0 Locally with MAMP

November 15, 2014

I’m currently in the process of building an e-commerce website for a startup I’m involved in. For this project, I decided to try developing a WordPress site on a local server for the first time. WordPress requires MySQL and PHP, so a piece of software called MAMP is needed to create a local development server. After piecing together a few online tutorials and videos, I was able to get a install of WordPress 4.0 running with the latest version of MAMP. Here’s how I did it.

First, download WordPress and the free version of MAMP. Run the MAMP installer, then navigate to /Applications/MAMP/ and run MAMP.app.

By default, MAMP’s document root is /Applications/MAMP/htdocs/. For users who wish to specify a custom document root, this setting can be changed in the Web Server settings in MAMP preferences. For this tutorial, I’ll be using the default document root. The default MAMP ports should be fine, so click on Start Servers.

WordPress requires a database to function, so you’ll need to create one with phpMyAdmin. Click on the Databases tab, type in your desired database name, and click Create. You should now see a database named wordpress.

Unzip wordpress.zip and move it to /Applications/MAMP/htdocs/. Navigate to /Applications/MAMP/htdocs/wordpress/ and change the name of wp-config-sample.php to wp-config.php. This is the WordPress configuration file that contains information about your web server and database, among other things.

Open up wp-config.php in your favorite text editor (I use Sublime Text), and scroll until you see the following lines.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'database_name_here');
/** MySQL database username */
define('DB_USER', 'username_here');
/** MySQL database password */
define('DB_PASSWORD', 'password_here');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
Replace 'database_name_here' with 'wordpress', 'username_here' with 'root', and 'password_here' with 'root'. The result should look like this.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'root');
/** MySQL database password */
define('DB_PASSWORD', 'root');
/** MySQL hostname */
define('DB_HOST', 'localhost');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');
Now, navigate to localhost:8888/wordpress/ to complete WordPress setup. That's it! Let me know if this works for you in the comments section below.

Questions?

Find me on Twitter, or send me an email.