Post MAMP install setup to add SSL

First install the basic MAMP package from www.mamp.info (not MAMP Pro).

Once the MAMP package has finished installing, edit the /Applications/MAMP/bin/startApache.sh file and change the first argument from start to startssl and save the file. This tells Apache to enable SSL when it tries to start.

Next we are going to add some virtual hosts so that we can run a few different sites at once from our MAMP install. Edit the /Applications/MAMP/conf/apache/httpd.conf file and set up your virtual hosts. The basic set up for a virtual host will be

NameVirtualHost *:80
<VirtualHost *:80>
    DocumentRoot /www/localhost
    ServerName localhost
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot /www/specific-host
    ServerName specific-host
    ServerAlias www.specific-host
</VirtualHost>

The first virtual host will be the default one (if there is no ServerName or ServerAlias set up for the url you are accessing the site via). There is a way to let you specific the default virtual host explicitly but I won't cover that here since I find having the first virtual host act as the default easy enough.

This assumes that you have created a /www/localhost and a /www/specific-host directory on your hard drive that you are going to put all your web files in.

The specific-host section is just an example on how you can specify a second (or third) alternate site coming from the same site. I generally add an entry to my hosts file for development sites where necessary. In this case you would add the line

127.0.0.1 specific-host

to your /etc/hosts file so that you could put in http://specific-host/ in your browser to get to the site.

Generate your ssl key and certificate. There are lots of examples on the net on how to generate a self signed SSL certificate for Apache.

Edit the /Applications/MAMP/conf/apache/ssl.conf file and set up the SSL virutal host. It is going to be a matter of setting the following settings in the ssl.conf either by uncommenting them or adding them.

DocumentRoot - This should be set to the directory with the files you want to server. In our example above if we also wanted specific-site to work under SSL then we would set this to /www/specific-site ServerName - For SSL this doesn't really matter since you can only have 1 site per ip but you should set it to the name that people will be visiting the site via. SSLCertificateFile - The key file you generated in step 3 SSLCertificateKeyFile - The signed certificate file you generated in step 3