如何使用 MAMP 在 Apache 服务器 运行 中包含 SSL 证书文件
How to include SSL certificate files in Apache Server running using MAMP
我已经创建了 SSL 证书,以便为本地主机使用 https 而不是 http。我遵循的说明在这里:https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec
我还有最后一步,就是在服务器中包含证书文件(server.crt 和 server.key)。
我试图依靠以下配置使其工作,我从中获得:
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
# maybe additional config here
ServerName www.example.com
SSLEngine on
SSLCertificateFile "/path/to/www.example.com.cert"
SSLCertificateKeyFile "/path/to/www.example.com.key"
</VirtualHost>
我目前在 mac 上使用 MAMP,并使用 Apache 作为服务器。我编辑了位于 Applications/MAMP/conf/apache 的文件 httpd.conf,并在文件底部添加了以下内容:
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
ServerName localhost:443
SSLEngine on
SSLCertificateFile "~/server.crt"
SSLCertificateKeyFile "~/server.key"
</VirtualHost>
请注意我的 SSL 文件位于 ~ 目录中。我也在这个文件中用443更新了8888个条目,它们是:
Listen 443
ServerName localhost:443
我重启服务器后,再次启动失败!
这是提供解决方案的视频:https://www.youtube.com/watch?v=886Pea2ljm0&t=2s
重要提示:如果从 MAMP 重新启动服务器时出现以下错误:
Apache couldn't be started. Please check your MAMP installation and
configuration.
运行 在终端上执行以下命令并且有效:
sudo /Applications/MAMP/Library/bin/apachectl start
MAMP 在主机设置中有一个额外的 SSL 部分。无需编辑 conf 文件。
我已经创建了 SSL 证书,以便为本地主机使用 https 而不是 http。我遵循的说明在这里:https://medium.freecodecamp.org/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec
我还有最后一步,就是在服务器中包含证书文件(server.crt 和 server.key)。
我试图依靠以下配置使其工作,我从中获得:
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
# maybe additional config here
ServerName www.example.com
SSLEngine on
SSLCertificateFile "/path/to/www.example.com.cert"
SSLCertificateKeyFile "/path/to/www.example.com.key"
</VirtualHost>
我目前在 mac 上使用 MAMP,并使用 Apache 作为服务器。我编辑了位于 Applications/MAMP/conf/apache 的文件 httpd.conf,并在文件底部添加了以下内容:
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
ServerName localhost:443
SSLEngine on
SSLCertificateFile "~/server.crt"
SSLCertificateKeyFile "~/server.key"
</VirtualHost>
请注意我的 SSL 文件位于 ~ 目录中。我也在这个文件中用443更新了8888个条目,它们是:
Listen 443
ServerName localhost:443
我重启服务器后,再次启动失败!
这是提供解决方案的视频:https://www.youtube.com/watch?v=886Pea2ljm0&t=2s
重要提示:如果从 MAMP 重新启动服务器时出现以下错误:
Apache couldn't be started. Please check your MAMP installation and configuration.
运行 在终端上执行以下命令并且有效:
sudo /Applications/MAMP/Library/bin/apachectl start
MAMP 在主机设置中有一个额外的 SSL 部分。无需编辑 conf 文件。