Localhost - Xampp 中的 OpenSSL Mac OSX

Localhost - OpenSSL in Xamp Mac OSX

首先,我在终端上使用以下命令得到 localhost.csr、localhost.key 和 localhost.crt:

要求:

openssl req -new -newkey rsa:2048 -nodes -keyout localhost.key -out localhost.csr 

证书:

openssl x509 -req -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt

我关注了这个问题 here 并在 httpd-ssl.conf:

上更新了这些 directives 内容
SSLCertificateKeyFile "/Applications/XAMPP/xamppfiles/apache2/ssl-certs/localhost.key"
SSLCertificateFile "/Applications/XAMPP/xamppfiles/apache2/ssl-certs/localhost.crt"

在 MyApache 中,启用了 SSL。当我重新启动本地主机并转到 http://localhost 时,绿色标志出现但我得到:

Access Forbidden Error 403
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

如果我使用普通 http://localhost,网站加载正常。

请让我知道我的错误。我是 SSL 事物和指令的新手。

好吧,我终于想通了,必须将两个不同端口的虚拟主机设置为:

<VirtualHost localhost:80>
    ServerName localhost
    DocumentRoot "/Users/tikadattapahadi/web"
    <Directory  "/Users/tikadattapahadi/web">
        Options Indexes FollowSymLinks Includes execCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


<VirtualHost localhost:443>
    SSLEngine on
    ServerName localhost

    SSLCertificateFile "/Applications/XAMPP/xamppfiles/apache2/ssl-certs/localhost.crt"
    SSLCertificateKeyFile "/Applications/XAMPP/xamppfiles/apache2/ssl-certs/localhost.key"


    DocumentRoot "/Users/tikadattapahadi/web/"
    <Directory "/Users/tikadattapahadi/web/">
        Options Indexes FollowSymLinks Includes execCGI
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>