Working Ninja
2014-04-05T17:40:11
MAMP Development Server Setup

Here’s the lowdown on how I setup my MAMP (Mac, Apache, MySQL and PHP) server for local web development and the steps I went through to create a development environment for a site already in production.

Configuring Apache

Apache comes preinstalled with OS X so I decided to stick with it in an effort to save time. Apache, though, thought it would rally around my optimism and not allow me to access the default DocumentRoot (~/user). After trying another directory inside my user folder I recalled clamping down permissions on my user folder which would have denied access to _www. Instead of adding back permissions, I decided to move DocumentRoot outside of ~/user and moved it to /Sites. Voilà!

Also, by default, the bind address inside httpd.conf is set to all IP Addresses available on your machine. I disabled this by binding the url to only 127.0.0.1 so that I wouldn’t have anyone snooping around my development sites at the coffee shop =)

Enabling PHP

Enabling PHP was probably the easiest part of the setup. All that was required here was to uncomment the following line in httpd.conf:
#LoadModule php5_module libexec/apache2/libphp5.so

Install and Configure MySQL

Installed MySQL Community Server.
Started MySQL via System Preference pane.
(Note: for increased security, don’t allow MySQL to accept incoming connections).

Install and Configure phpMyAdmin

To administer MySQL, I decided to install phpMyAdmin. I had an issue with MySQL’s config directory not being writable even though permissions were set correctly. I found that others had had the same issue and were able to get around this by manually creating the config.inc.php file. I was also able to get around the config directory error but, alas, the next hurdle was before me.

I was now presented with ‘unable to log into phpMyAdmin (root login w/o password not allowed)’. Fairly straightforward, I set the root password for MySQL and also set config.inc.php to use 127.0.0.1 instead of localhost (to match DocumentRoot in httpd.conf).

Database Creation + Export from Production + Import for Development

With phpMyAdmin properly setup, I created a new database and user (from wp-config.php) to house a copy of the production database.

At the production end, I exported the production database and then imported to development environment. With WordPress files and database now in place, I loaded up the login page. And yes, a few things left to configure =)

Troubleshoot WordPress Issues

Unable to login
Needed to update siteurl and home in wp_options table to reflect change of address (e.g. http://domain.name is now http://127.0.0.1/domain.name).

mysql.sock error
I also received a mysql.sock error which was resolved by updating the hostname in wp-config.php to 127.0.0.1 from localhost (same as phpMyAdmin).

Unable to access pages other than index
Found that WordPress permalinks aren’t working (for pages). Created .htaccess file but no change and gave _www 660 permissions (PHP can now write to .htaccess through Apache). Also needed to set AllowOverwrite All in httpd.conf to allow .htaccess.

My process could more than likely be improved but I sure did learn a lot along the way.