Enable SSL in MAMP 2.0.5

Enable SSL in MAMP 2.0.5


If you are at all serious about PHP development on OSX, then you are probably familiar with the usefulness of having MAMP installed. In under 20 minutes, you can set up multiple local development environments all managed by git and accessible through virtual hosts with little to no configuration. Add another 10 minutes, and you can easily enable SSL in MAMP 2.0.5

I am working with several sites that utilize HTTPS, and I wanted to make the development process reflect the live environment as much as possible. MAMP Pro makes this process a snap; all you have to do is click the ‘Enable SSL’ checkbox in the most recent versions and you are set. For those of us without $59.95 to spend at the moment, it is possible to enable SSL in MAMP 2.0.5 – it just requires a little manual editing.

Most articles on enabling SSL in MAMP are pretty outdated and are no longer accurate due to files moving and/or being removed. Luckily, MAMP has actually made things easier for us to set up SSL by using includes and allowing us to put the proper configuration code in relevant files. We will be following a lot of the same steps from this older article, but here I’ll show you how to do it with the newest version.

Step 1: Back that MAMP up!

Before you do anything, go ahead and back up your MAMP configuration folder /Applications/MAMP/conf/ by either turning it into a local GIT repository or making some kind of backup/duplicate of this folder. If you have GIT installed, enter the following commands in terminal.

Step 2: Generate an SSL Certificate

Now, we need to create a self signed SSL certificate that we can use with MAMP. This process is a little cryptic if you’ve never done it before, but if you follow the steps below everything should be fine. In terminal, enter the following commands.

Step 3: Uncomment the Includes

There are a few files we need to include in apache in order to get everything up and running. In my case, I am creating virtual hosts for each of my sites so I can access them with a simpler URL than the default htdocs/mysite.com, so I’ll be including the virtual hosts configuration file as well as the ssl configuration file.

Open /Applications/MAMP/conf/apache/httpd.conf in your preferred code editor and go to line 525:

Uncomment it (remove the ‘#’) so it looks the same as below:

Then, find line 537:

Uncomment it as shown below:

Step 4: Add your Virtual Host

If you haven’t yet set up a virtual host servername in your local hosts file, you may want to do that next.

  • In finder, select ‘Go to Folder’ from the ‘Go’ dropdown menu.
  • In the dialog box, enter /private/etc/ and click ok.
  • Open the hosts file in your text editor and add the following code on a new line under 127.0.0.1 localhost, where ‘blog’ is the name of your desired servername:

Now we just need to pay a visit to each of the files that we just included and add a few settings.

In /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf, add the following code to the bottom of the file (somewhere near line 44). Of course, you’ll need to change the ServerName and DocumentRoot directives to the virtual host name and path that works with your environment:

Step 5: Edit the SSL Configuration

Last step! In /Applications/MAMP/conf/apache/extra/httpd-ssl.conf, find this code block around line 76:

and edit in your DocumentRoot and ServerName settings:

And there you have it! Since the certificate we generated isn’t actually a valid certificate, you’ll need t add it as a security exception in your browser for https to work. And of course, when using SSL online, be sure to purchase your certificate from a reliable vendor.

Happy secure MAMPing!

Comments are closed.