How To Enable SSL in MAMP

In my developer toolbox post, I’ve covered that I prefer to use to MAMP for local development. For the most part, the default settings (or some variation thereof) work just fine; however, if you end up needing to do some work on a secure site, then you’ll need enable SSL in MAMP.

On production-level servers, you’ll need to have purchased an SSL certificate; however, MAMP makes it trivially easy to setup a certificate in your development environment.

Enable SSL in MAMP

The only caveat to setting up SSL on your development machine is that you have to define a local server other than localhost (but this is easy to do).

Other than that, it’s just a few simple steps.

1. Load MAMP

MAMP Homescreen

First, load MAMP and make sure that you’re on the homescreen. If you’re more comfortable with MAMP, then it doesn’t really matter which screen you start on – this step ensures that we’re all on the same page.

2. Define a New Host

Click on the “Hosts” tab to view the list of the hosts you’ve configured. Some of you will only have ‘localhost’, others of you will have more.

MAMP Hosts Tab

Regardless, click on the ‘+’ button right below the list of hosts to add a new host. This will automatically insert a new line item into the list of hosts and will display a set of fields for you to populate:

MAMP New Host

Make sure that you click on the ‘SSL’ check box:

Enable SSL in MAMP

Then select the directory out of which your site, application, or files will be served:

MAMP Directory

3. Generate an SSL Certificate

After that, click on the ‘SSL’ tab. Initially, you should see two fields each of which have an exclamation point beside them:

MAMP SSL Tab

Next, click on the ‘Create Self-Signed Certificate’ button and a new dialog will appear prompting you to populate it with certain information:

Create SSL Certificate in MAMP

Fill out this information. Feel free to be as accurate – or inaccurate) – as you want as this information is kept on your local machine:

Generate MAMP SSL Certificate

Finally, click on ‘Generate’ and you’ll be asked where to save the certificate file. Feel free to choose any location. I’m a fan of keeping the certificate file in the same location of the project just to keep things organized.

4. Done!

Once you’ve generated the certificate, MAMP will automatically populate the fields with the locations of both the certificate file and the key file.

Save MAMP SSL Certificate

Finally, restart your server.

Once the server has restarted, you can navigate to your secure site using the host you defined earlier in this process. In my case, it would be https://examplehost.net. Remember to prefix the location with https; otherwise, it won’t load.

And that’s how you enable SSL in MAMP. Easy enough, right?

16 Replies to “How To Enable SSL in MAMP”

    1. Honestly, I’ve rarely had to work in that specific scenario. Instead, I used WordPress’ is_ssl() function to handle the code in my development environment; however, the certificate would still have to be loaded in production for that specific page.

      If that’s the case, it can likely be done programmatically. I’ve just not had to handle that. At least not yet :).

  1. Just some quick additions.

    If you only setup the one virtual host with SSL the non-secure version (http) will not be accessible for MAMP. In order to have both http and https, just repeat the process with the same server name, but without the SSL setup.

    To enable https only for specific sections of your site you could set that up in your .htaccess file like so:

    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteCond $1 ^(member|account|checkout) [NC]
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    For example this would force https on only the sections that have “member”, “account” or “checkout” in the URL.

  2. Awesome guide! Thanks for this.
    It is also worth mentioning that the SSL that you create needs to be in the same project folder in your MAMP directory or else the “Apply” button is not clickable. Took me quite a while to figure that one out as I was saving the certificates to my desktop.

    Cheers!

  3. Thanks, Tom. This is extremely helpful. One thing, though — your first screenshot shows you’ve got your Apache / SSL / MySQL ports set to 80 / 443 / 3306. I think you have to have these settings in place to make this process work, correct? If you have them set to MAMP’s settings (8888 / 8890 / 8889), it won’t work. And if you try to switch from 8888 / 8890 / 8889 to 80 / 443 / 3306, MAMP will tell you that you first have to disable the built-in Apache. What’s your preferred method for doing that?

    1. Ah, that’s a good catch.

      I always use the default ports for Apache, SSL, and MySQL — that is to say that I don’t use MAMP’s ports. The other ports (that is, 80 / 443 / 3306) are the default ports for that software, so you can either click on the option in MAMP to revert to those or manually specify them.

      Those are really the only settings I’ve changed.

  4. Tom, I know this tut is a bit dated but do you have instructions for applying a real SSL cert to a live version of MAMP Pro, or perhaps a link I can’t seem to locate on Google? Thanks so much.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.