使用XAMPP启用SSL

Col*_*acX 76 xampp ssl https http-status-code-404

我一直在关注本指南,尽可能多地 http://robsnotebook.com/xampp-ssl-encrypt-passwords.

但是,每当我浏览到以https开头的页面时,apache服务器都会回复404 Object Not Found.

我缺少什么设置?谢谢你的帮助.

Col*_*acX 102

找到了答案.在文件中xampp\apache\conf\extra\httpd-ssl.conf,在SSL Virtual Host Context端口443上的注释页面下,意味着在不同的文档根目录下查找https.

只需将文档根目录更改为同一个,问题就解决了.

  • 请记住,您还需要重新启动Apache才能使这些更改生效(您可能需要禁用并重新启用SSL才能看到它正常工作,使用`sudo/Applications/XAMPP/xamppfiles/xampp disablessl`和`sudo/Applications/XAMPP/xamppfiles/xampp enablessl`). (9认同)
  • 别忘了转发端口443用于SSL.希望可以帮助某人=) (4认同)

Tob*_*ann 79

您还可以xampp/apache/conf/extra/httpd-vhost.conf像这样配置SSL :

<VirtualHost *:443>
    DocumentRoot C:/xampp/htdocs/yourProject
    ServerName yourProject.whatever
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/server.crt"
    SSLCertificateKeyFile "conf/ssl.key/server.key"
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

我想,httpd-ssl.conf如果你有多个项目并且你需要多个SSL上的SSL,最好不要改变它


Pri*_*ari 11

对于XAMPP,请执行以下步骤:

  1. G:\ XAMPP\apache的\的conf \额外\的httpd-ssl.conf中"

  2. 搜索"DocumentRoot"文字.

  3. 将DocumentRoot DocumentRoot"G:/ xampp/htdocs"更改为DocumentRoot"G:/ xampp/htdocs/project name".


Ami*_*mit 7

在xampp / apache / conf / extra / httpd-vhost.conf中配置SSL

http

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/myproject/web"
    ServerName www.myurl.com

    <Directory "C:/xampp/htdocs/myproject/web">
        Options All
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

https

<VirtualHost *:443>
    DocumentRoot "C:/xampp/htdocs/myproject/web"
    ServerName www.myurl.com
    SSLEngine on
    SSLCertificateFile "conf/ssl.crt/server.crt" 
    SSLCertificateKeyFile "conf/ssl.key/server.key"
    <Directory "C:/xampp/htdocs/myproject/web">
        Options All
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)

确保正确指定server.crt和server.key路径,否则将无法正常工作。

不要忘记在httpd.conf中启用vhost

# Virtual hosts
Include etc/extra/httpd-vhosts.conf
Run Code Online (Sandbox Code Playgroud)


Adr*_* P. 6

这里有一个更好的 Windows 指南:

https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/

基本步骤:

  1. 使用此方法为您的本地域创建 SSL 证书:请参阅上面的链接中的更多详细信息 https://gist.github.com/turtlepod/3b8d8d0eef29de019951aa9d9dcba546 https://gist.github.com/turtlepod/e94928cddbfc46cfbaf8c3e5856577d0

  2. 在 Windows(受信任的根证书颁发机构)中安装此证书请参阅上面的链接查看更多详细信息

  3. 在 Windows 主机 (C:\Windows\System32\drivers\etc\hosts) 中添加站点,例如:127.0.0.1 site.test

  4. 在 XAMPP conf (C:\xampp\apache\conf\extra\httpd-vhosts.conf) 中添加站点,例如:

     <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs"
        ServerName site.test
        ServerAlias *.site.test
     </VirtualHost>
     <VirtualHost *:443>
        DocumentRoot "C:/xampp/htdocs"
        ServerName site.test
        ServerAlias *.site.test
        SSLEngine on
        SSLCertificateFile "crt/site.test/server.crt"
        SSLCertificateKeyFile "crt/site.test/server.key"
     </VirtualHost>
    
    Run Code Online (Sandbox Code Playgroud)
  5. 重新启动 Apache 和浏览器即可完成!