Create a gist now

Instantly share code, notes, and snippets.

@jfloff /
Last active Apr 18, 2017

What would you like to do?
How to get MAMP to work with SSL ... Yes really.

First of all you need to be able to run MAMP in port 80. This is a "heat check" if you don't have any process jamming http ports. You can check it like this:

sudo lsof | grep LISTEN

If you do happen to have any process with something like this *:http (LISTEN), you are in trouble. Before with adventure check if it isn't MAMP itself (yeah, you should close that beforehand)

ps <pid of that process>

If you don't see MAMP, you are in good hands, I have just the thing for you:

# I've forced the removal of the job
$ launchctl remove org.apache.httpd

# and load it again
$ launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

# and unload it again
$ launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

Now you should be able to use port 80 (and almost any other) in MAMP. Just go to MAMP > Preferences > Ports Tab and click the Set to default Apache and MySQL ports.

Now comes the easy part, you just have to follow what this guy wrote here. Well, that's copy that here just in case ...

  1. Backup your /Applications/MAMP/conf/ dir.

  2. Generate a (dummy) SSL Certificate

    $ cd ~
    # generate a private key (will request a password twice)
    $ openssl genrsa -des3 -out server.key 1024
    # generate certificate signing request (same password as above)
    $ openssl req -new -key server.key -out server.csr
    # Answer the questions
    Country Name (2 letter code) [AU]: CA
    State or Province Name (full name) [Some-State]: Quebec
    Locality Name (eg, city) []: Montreal
    Organization Name (eg, company) [Internet Widgits Pty Ltd]: Your Company
    Organizational Unit Name (eg, section) []: Development
    Common Name (eg, YOUR name) []: localhost
    Email Address []:
    A challenge password []: # leave this empty
    An optional company name []: # leave this empty
    # generate the certificate
    $ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
    # remove the password from the server key
    $ cp server.key server.tmp
    $ openssl rsa -in server.tmp -out server.key
    # Move the certificate into your MAMP apache configuration folder
    $ cp server.crt /Applications/MAMP/conf/apache
    $ cp server.key /Applications/MAMP/conf/apache
  3. Open /Applications/MAMP/conf/apache/httpd.conf and uncomment Include /Applications/MAMP/conf/apache/extra/httpd-ssl.conf.

  4. Keep your vhost in /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf just the same.

  5. In /Applications/MAMP/conf/apache/extra/httpd-ssl.conf, find the following block and edit the fields Server Name and Document Root with the values you already have in your vhost.

    #   General setup for the virtual host
    DocumentRoot "/Applications/MAMP/Library/htdocs"
    ErrorLog "/Applications/MAMP/Library/logs/error_log"
    TransferLog "/Applications/MAMP/Library/logs/access_log"
    and edit in your DocumentRoot and ServerName settings:

Happy secure MAMPing!

Who are the people developing MAMP?

"hey guys, lets change everything, but not tell anyone so they'll have some fun figuring out how to get things working again."

Unbelievable. Well, changelog then, anyone? ...NOOOOOPE ! (Search for changelog: ....NOOOOOPE).
google 'MAMP changelog': ....NOOOOOPE.


Anyway thanks for figuring this out!

oh, double check if everything is well:

? > apachectl OR if you haven't added all MAMP binaries to your path:
? > /Applications/MAMP/bin/apache2/bin/apachectl

purefan commented Nov 17, 2015

I made some edits to your gist, mostly grammar, so feel free to add them to your gist if you feel they're good enough:

Could someone upload somewhere? I had SSL working on MAMP until the file disappeared from my computer and I can't find it anywhere. My PHP version is 5.6.2.

Thank you.

This seems find a for a single hosted solution, but if you are running MAMP locally for localhost development, how would you accommodate multiple ServerName declarations if we are only using the default:443 VirtualHost that is provided in the file? Could you just create additional VirtualHosts (logical assumption on my end)?

h311o commented Jan 23, 2016

When I try and access "", I am accessing an online domain "established to be used for illustrative examples in documents"?

Did not work at all for me.

Very helpful. Worked for me. Thanks a lot.:)

what if i have the CRS, CRT, CA files from comodo? how can i generate private key from this files?

I've tried this about 8 times already and cannot get it to work - not sure if I'm missing something here.

Question about point 5. I have loads of accounts set up under vhosts, how do I configure the general vhost setup?

Just in case if you are getting a "404 Not Found The requested URL was not found on this server", just make sure that the DocumentRoot in httpd-ssl.conf is correct, mine was pointing to a useless address. :)

How would I access only one page via virtual host (mypage.local for example) using https ? for me it does not seem to work, and also this forces https - if I try accessing localhost without https it says

Bad Request Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

So simple, thank you for this guide

Pretty easy!!! 😄

johnmap commented Jan 25, 2017

Thank you so so so much. This fixed my problem with relatively little hassle.

However, WTF MAMP? The purpose of purchasing MAMP PRO is to avoid this kind of messing around. Have opened a ticket with them.

Meh, tried everything. Not working for me.

I am currently running macOS 10.12.1 with a purchased version of MAMP Pro 4.1 and I am unable to get MAMP PRO running with an SSL so I tried your advice:
After checking to see if I have any processes running using: sudo lsof | grep LISTEN
I see that I am indeed "in trouble"
What steps should I take now? Thanks in advance.

Thanks for the tutorial. Works nicely for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment