如果您正在使用曼普 3 或 4说明略有不同。
以下是对我有用的方法,从在没有 Pro 的 Mavericks 上全新安装 MAMP 3.0.5 开始。
更新:按照中所述修复 Apache 后,仍然可以在 Yosemite 上使用这个答案 https://stackoverflow.com/a/25212463/149097.
进一步更新:评论表明这至少仍然有效MAMP 5.4.
生成证书
这部分直接来自教程,因此如果您已经这样做了,您可以跳到“设置 MAMP”。
使用终端在默认文件夹中生成私钥:
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] /cdn-cgi/l/email-protection
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
设置 MAMP 3.0.5
这是与以前版本的说明略有不同的地方。文件名和位置已更改,conf 文件中的某些命令也不同。以下是在全新安装 MAMP 3.0.5 时对我有用的内容。
将证书文件(server.key 和 server.crt)移动到:
/应用程序/MAMP/conf/apache/
打开Apache的httpd.conf文件:
/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
保存并关闭。现在打开 Apache 的 ssl conf 文件:
/Applications/MAMP/conf/apache/extra/httpd-ssl.conf
找出<VirtualHost>
条目(文件末尾的大块以<VirtualHost _default_:443>
并以</VirtualHost>
)并将整个内容替换为:
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /Applications/MAMP/conf/apache/server.crt
SSLCertificateKeyFile /Applications/MAMP/conf/apache/server.key
</VirtualHost>
保存并关闭。启动您的 MAMP 服务器。您应该能够访问您的文档根目录http://localhost
and https://localhost
.