To set up SSL on a virtual host on MAMP you would need to edit the apache configuration files which are located on the /Applications/MAMP/conf folder, and to create a self-signed certificate.
Locate the file /Applications/MAMP/conf/apache/httpd.conf and open it with a text editor.
Then proceed to uncomment the following line:
#Include /Applications/MAMP/conf/apache/extra/httpd-ssl.conf
Now we generate the certificate files.
Open a Terminal window, and go the apache configuration folder.
cd /Applications/MAMP/conf/apache/
We start by generating the private key file "server.key"
openssl genrsa -des3 -out server.key 2048
The command will request us to enter a password.
Then, generate the certificate signing request
openssl req -new -key server.key -out server.csr
After that, we generate the certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
And at last we remove its password
cp server.key server.tmp
openssl rsa -in server.tmp -out server.key
Edit the file /Applications/MAMP/conf/apache/extra/http-ssl.conf.
Find the following line.
Listen 443
And replace it with these lines.
Listen 8890
NameVirtualHost *:8890
SSLStrictSNIVHostCheck off
Also find the following tag.
<VirtualHost _default_:443>
And replace it with this.
<VirtualHost _default_:8890>
Find the following lines.
DocumentRoot "/Applications/MAMP/Library/htdocs"
ServerName www.example.com:443
ServerAdmin you@example.com
ErrorLog "/Applications/MAMP/Library/logs/error_log"
TransferLog "/Applications/MAMP/Library/logs/access_log"
And replace them with these lines.
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost:8890
ServerAdmin you@example.com
ErrorLog "/Applications/MAMP/logs/error_log"
TransferLog "/Applications/MAMP/logs/access_log"
Finally, at the bottom of the file, add the VirtualHost entries for the sites you want to use https://
<VirtualHost *:8890>
DocumentRoot "/Applications/MAMP/htdocs/mydomain.dev/public_html"
ServerName mydomain.dev
<Directory "/Applications/MAMP/htdocs/mydomain.dev/public_html">
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Now, restart your MAMP server, and you can open your local secure site, on the 8890 port.
https://mydomain.dev:8890