为 SSL 配置 MAMP [英] Configuring MAMP for SSL

查看:24
本文介绍了为 SSL 配置 MAMP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的编码人员,我正在尝试在我的 mac 上使用 SSL 配置 MAMP 以用于开发目的.我已阅读并尝试了以下说明:
http://www.emersonlackey.com/article/mamp-with-ssl-httpshttp://www.webopius.com/content/355/getting-mamp-working-with-ssl-on-os-x

Ok fellow coders, I am trying to configure MAMP with SSL on my mac for development purposes. I have read and tried the following instructions:
http://www.emersonlackey.com/article/mamp-with-ssl-https http://www.webopius.com/content/355/getting-mamp-working-with-ssl-on-os-x

没有运气.我可以使用 http 访问 127.0.0.1 或 localhost 但 https://localhosthttps://127.0.0.1 都返回主机发现错误.

with no luck. I can hit either 127.0.0.1 or localhost with http but both https://localhost and https://127.0.0.1 return host not found error.

查看 phpinfo,我看不到正在加载 mod_ssl.

looking at phpinfo, i can't see mod_ssl being loaded.

有人用 os x 10.6.7 做过这个吗?我不知道从这里去哪里.

has anyone done this with os x 10.6.7? i have no idea where to go from here.

希望有人能帮忙.

谢谢

------编辑开始------

------edit start------

以下是我对配置文件所做的更改,以使 https 正常工作.请按照上面列出的步骤创建证书/密钥并删除密码(@dallas 下面也提到了这一点).

the following are the changes i have made to the config files to get https working. Please follow the tuts listed above to get the certificate/key created and the password removed (as also mentioned by @dallas below).

httpd.conf

注释掉 ifdef 以确保 LoadModule 被执行

Comment out the ifdef to make sure LoadModule is executed

#<IfDefine SSL>
    LoadModule ssl_module modules/mod_ssl.so
#</IfDefine>

确保以下内容在文件中...

make sure the following is in the file...

Listen 80
ServerName localhost:80

ssl.conf

添加以下内容....

<VirtualHost localhost:443>
    DocumentRoot /Users/myname/Documents/DevProjects/WebdevProjects
    ServerName localhost
    SSLEngine on
    SSLCertificateFile /Applications/MAMP/conf/ssl/server.crt
    SSLCertificateKeyFile /Applications/MAMP/conf/ssl/server.key
</VirtualHost>

在现有

<VirtualHost _default_:443>

server.crt 和 server.key 是根据上述链接新建的.

server.crt and server.key are the newly created ones as per the obove tuts' links.

注释掉

#<IfDefine SSL> 

围绕第 35 行及其结束标记围绕第 245 行以启用该行...

around line 35 and its closing tag around line 245 to enable the line...

Listen 443

在两者之间,根据上述 VirtualHost 定义更新对新创建文件的所有证书引用.

in between, update all certificate references to the newly created files as per the above VirtualHost definition.

推荐答案

如果您使用 MAMP 3 或 4,说明略有不同.以下是对我有用的方法,从在没有 Pro 的 Mavericks 上全新安装 MAMP 3.0.5 开始.

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.

更新:按照此答案中所述修复 Apache 后,仍可在 Yosemite 上运行.

Update: Still works on Yosemite after fixing Apache as described in this answer.

进一步更新:评论表明这至少在 MAMP 5.4 中仍然有效.

Further Update: Comments suggest this still works at least through MAMP 5.4.

生成证书

这部分直接来自教程,所以如果你已经做过了,你可以跳到设置 MAMP".

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@example.com
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 时对我有用的内容.

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.

将证书文件(server.key 和 server.crt)移动到:

Move the certificate files (server.key and server.crt) to:

/Applications/MAMP/conf/apache/

/Applications/MAMP/conf/apache/

打开 Apache 的 httpd.conf 文件:

Open Apache's httpd.conf file:

/Applications/MAMP/conf/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文件:

Save it and close. Now open Apache's ssl conf file:

/Applications/MAMP/conf/apache/extra/httpd-ssl.conf

/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>

保存并关闭.启动您的 MAMP 服务器.您应该能够通过 http://localhosthttps://localhost 访问您的文档根目录.

Save and close. Start your MAMP server. You should be able to access your document root at http://localhost and https://localhost.

这篇关于为 SSL 配置 MAMP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆