Usable MAMP on OS X 10.8 Mountain Lion

Alan Ivey's picture

Senior Systems Administrator


Usable MAMP on OS X 10.8 Mountain Lion

MAMP on OS X is a great way to quickly get started on Apache/MySQL/PHP development locally on a Mac. Unfortunately, I've found that many of the defaults can get in the way of developing some content management systems, like Drupal. The following are a list of steps aimed to help you get MAMP installed and configured to be much more friendly to development projects in Drupal or WordPress. It'll also set you up for VirtualDocumentRoot, which is a faster way to create new projects. Read on to get started.

Install MAMP

Download the latest MAMP from and run the installer.

Choose APC Cache

Open the MAMP app, open Preferences..., click the PHP tab, and change Cache to APC. Click OK to close Preferences and Quit MAMP.

MAMP Screenshot

PATH variable

From here on out, you'll be copying and pasting commands into Terminal. If you're new to getting this deep into the system, just copy and paste carefully and hit return after each command you paste. Some commands begin with the # character; they are comments and will have no effect.

Put MAMP binaries, including PHP, in the front of your $PATH (this is a single command):

echo 'export PATH="/Applications/MAMP/bin:/Applications/MAMP/Library/bin:$(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/bin:$PATH"' >> ~/.bash_profile && source ~/.bash_profile


Set up MySQL and stop it (default MySQL password is root, you do not have to change it when running mysql_secure_installation, though I recommend all of the other defaults):

cp -va /Applications/MAMP/Library/support-files/my-small.cnf /Applications/MAMP/conf/my.cnf
sed -i '' "s/^\(max_allowed_packet =\) [0-9]*M/\1 1G/g" /Applications/MAMP/conf/my.cnf
egrep "^# Uncomment the following if you are using InnoDB tables$" /Applications/MAMP/conf/my.cnf &>/dev/null && sed -i '' "s/^\(# Uncomment the following if you are using InnoDB tables\)$/\1@innodb_file_per_table/; y/@/\n/; s/^#\(innodb_.*\)/\1/g" /Applications/MAMP/conf/my.cnf
/Applications/MAMP/bin/ &
# Secure MySQL setup:
# -- OR --
# Less secure MySQL setup:
#/Applications/MAMP/Library/bin/mysql -uroot -proot -e"DELETE FROM mysql.user WHERE User=''; DELETE FROM mysql.user WHERE User='root' AND Host!='localhost'; FLUSH PRIVILEGES;"


Set timezone, and increase timeouts and memory values:

sed -i '-default' "s|^;*\(date\.timezone[[:space:]]*=\).*|\1 \"`systemsetup -gettimezone|awk -F"\: " '{print $2}'`\"|; s|^\(memory_limit[[:space:]]*=\).*\(\;.*\)|\1 256M \2|; s|^\(post_max_size[[:space:]]*=\).*|\1 200M|; s|^\(upload_max_filesize[[:space:]]*=\).*|\1 100M|; s|^\(default_socket_timeout[[:space:]]*=\).*|\1 600|; s|^\(max_execution_time[[:space:]]*=\).*\(\;.*\)|\1 300 \2|; s|^\(max_input_time[[:space:]]*=\).*\(\;.*\)|\1 600 \2|;" $(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/conf/php.ini
echo -e "\n[apc]\napc.shm_size = 192M\napc.rfc1867 = 1" >> $(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/conf/php.ini

PECL Uploadprogress

Feel free to skip: This is quite involved when the setting apc.rfc1867=1 set above does the job in most cases. This is mostly an exercise in building PHP modules for MAMP.

You'll need to install Xcode Command Line Tools from in order to complete all of the steps below.

mkdir -p $(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/include
cd $(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/include
export PHPVER=$(cd /Applications/MAMP/bin/php && find * -type d -name "php5.4*" | sort | tail -1 | sed 's/php//') && curl -L -o php-${PHPVER}.tar.bz2${PHPVER}.tar.bz2/from/ && unset PHPVER
ls php-5.4*bz2 | xargs -L1 tar jxpf && rm php-5.4*bz2
mv -v $(find * -type d -name "php-5.4*") php
cd php
cd ..
# Build automake and related tools
export build="$PWD/build"
mkdir -p $build
cd $build
curl -OL
tar xzf autoconf-2.68.tar.gz
cd autoconf-2.68
./configure --prefix=$build/autotools-bin
make install
export PATH=$PATH:$build/autotools-bin/bin
cd $build
curl -OL
tar xzf automake-1.11.tar.gz
cd automake-1.11
./configure --prefix=$build/autotools-bin
make install
cd $build
curl -OL
tar xzf libtool-2.4.tar.gz
cd libtool-2.4
./configure --prefix=$build/autotools-bin
make install
cd $build
unset build
rm autoconf-2.68.tar.gz automake-1.11.tar.gz libtool-2.4.tar.gz
rm -rf autoconf-2.68 automake-1.11 libtool-2.4
cd ..
pecl download uploadprogress
ls uploadprogress*z | xargs -L1 tar zxpf && rm -v uploadprogress*z package*xml
mv -v $(find * -type d -name "uploadprogress*") uploadprogress
cd uploadprogress
./configure --with-php-config=$(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/bin/php-config
make install
echo -e "\n[uploadprogress]\" >> $(find /Applications/MAMP/bin/php -type d -name "php5.4*" | sort | tail -1)/conf/php.ini

Reference 1:
Reference 2:


Set up VirtualHosts in ~/Sites/mamp-vhosts.conf so it's easy to edit later:

cp -av /Applications/MAMP/conf/apache/httpd.conf{,-default}
export USERHOME=$(dscl . -read /Users/`whoami` NFSHomeDirectory | awk -F"\: " '{print $2}') && echo -e "\n# User VirtualHosts file (added after MAMP installer)\nInclude ${USERHOME}/Sites/mamp-vhosts.conf" >> /Applications/MAMP/conf/apache/httpd.conf && unset USERHOME
[ ! -d ~/Sites/logs ] && mkdir -pv ~/Sites/logs

IMPORTANT! Be sure to copy and paste the lines containing PORTNUM through the last EOF as a single command (this entire block is a single copy+paste):

PORTNUM=$(egrep '^Listen [0-9]*' /Applications/MAMP/conf/apache/httpd.conf | awk '{print $2}') USERHOME=$(dscl . -read /Users/`whoami` NFSHomeDirectory | awk -F"\: " '{print $2}') cat > ~/Sites/mamp-vhosts.conf <<EOF
# Use name-based virtual hosting.
NameVirtualHost *:${PORTNUM}
# Set up permissions for VirtualHosts in ~/Sites
<Directory "${USERHOME}/Sites">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    Allow from all
# For http://localhost in the MAMP default location
<VirtualHost _default_:${PORTNUM}>
    ServerName localhost
    DocumentRoot "/Applications/MAMP/htdocs"
# VirtualHosts
## VirtualHost template
#<VirtualHost *:${PORTNUM}>
#  ServerName domain.local
#  CustomLog "${USERHOME}/Sites/logs/domain.local-access_log" combined
#  ErrorLog "${USERHOME}/Sites/logs/domain.local-error_log"
#  DocumentRoot "${USERHOME}/Sites/domain.local"
# Automatic VirtualHosts
# A directory at ${USERHOME}/Sites/webroot can be accessed at
# In Drupal, uncomment the line in .htaccess with: RewriteBase /
# This log format will display the per-virtual-host as the first field followed by a typical log line
LogFormat "%V %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedmassvhost
<VirtualHost *:${PORTNUM}>
  ServerName dev
  ServerAlias *.dev
  CustomLog "${USERHOME}/Sites/logs/dev-access_log" combinedmassvhost
  ErrorLog "${USERHOME}/Sites/logs/dev-error_log"
  VirtualDocumentRoot ${USERHOME}/Sites/%-2+

If you read that closely, you'll see that it's set up to do MassVirtualHosts using the *.dev tld. For example, set up a web root at $HOME/Sites/project and you will be able to view it at without needing to create a separate VirtualHost. A custom log format is used, putting the domain name at the beginning of the line, so you can easily see the output as it's related to a project.

Finishing Up

Open the MAMP application to Start Servers. Note that if you ever change the Apache port number, you'll need to edit ~/Sites/mamp-vhosts.conf appropriately.

As always with MAMP, you can work out of http://localhost:8888/ by putting files in /Applications/MAMP/htdocs. For example, the folder /Applications/MAMP/drupal will be accessible at http://localhost:8888/drupal. You can find other MAMP tools at http://localhost:8888/MAMP.

If you're having trouble connecting to MySQL with Sequel Pro or another utility, use /Applications/MAMP/tmp/mysql/mysql.sock as the socket path. If MAMP's MySQL is the only service running mysqld, this should not be necessary but YMMV.

Changing the defaults of MAMP is not trivial; perhaps it's easier to do if you pay for MAMP Pro. Hopefully, copying and pasting these commands will take care of the legwork for you and in the end you'll have a MAMP environment better suited for developing quickly on your Mac. If you have any questions or run into any problems, leave us a comment.

I see you like to read printed material. You should check out Nicco's book The End of Big: