If you're using MAMP 3 or 4 the instructions are slightly different.
Here's what worked for me, starting from a fresh install of MAMP 3.0.5 on Mavericks without Pro.
Update: Still works on Yosemite after fixing Apache as described in this answer.
Further Update: Comments suggest this still works at least through MAMP 5.4.
Generate the certificate
This part is straight from the tutorials, so if you already did it you can skip to "Set up MAMP".
Use the terminal to generate a private key in your default folder:
cd ~
# generate a private key
openssl genrsa -des3 -out server.key 2048
# make up a passphrase and remember it, you’ll need it 3 more times.
# generate certificate signing request
openssl req -new -key server.key -out server.csr
# same password
# answer the questions, use "localhost" for your Common Name
Country Name: US
State Name: California
Locality: My City
Organization: My Company
Organization Unit Name: # leave blank
Common Name: localhost
Email address: [email protected]
A challenge password: # leave blank
An optional company name: # leave blank
# generate the certificate from the CSR for 5 years
openssl x509 -req -days 1825 -in server.csr -signkey server.key -out server.crt
# remove the password requirement from the server key
cp server.key server.tmp
openssl rsa -in server.tmp -out server.key
Set up MAMP 3.0.5
Here's where the instructions from previous versions are a little off. The filenames and locations changed and some of the commands in the conf files are different. The following is what worked for me on a fresh install of MAMP 3.0.5.
Move the certificate files (server.key and server.crt) to:
/Applications/MAMP/conf/apache/
Open Apache's httpd.conf file:
/Applications/MAMP/conf/apache/httpd.conf
# set your listen port to 80 (near the top of the file)
Listen 80
# set your ServerName to localhost:80 (default is 8888)
ServerName localhost:80
# uncomment the line that includes the secure (SSL/TLS) connection conf
Include /Applications/MAMP/conf/apache/extra/httpd-ssl.conf
Save it and close. Now open Apache's ssl conf file:
/Applications/MAMP/conf/apache/extra/httpd-ssl.conf
Find the <VirtualHost>
entry (big block at the end of the file starting with <VirtualHost _default_:443>
and ending with </VirtualHost>
) and replace the entire thing with:
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /Applications/MAMP/conf/apache/server.crt
SSLCertificateKeyFile /Applications/MAMP/conf/apache/server.key
</VirtualHost>
Save and close. Start your MAMP server. You should be able to access your document root at http://localhost
and https://localhost
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…