Localhost - Xamp Mac OSX中的OpenSSL

时间:2015-05-29 02:26:27

标签: apache ssl

首先,我在终端上使用以下命令获得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。当我重新启动localhost并转到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事物和指令的新手。

1 个答案:

答案 0 :(得分:0)

好吧,我终于发现两个不同端口的虚拟主机必须设置为:

<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>
相关问题