让SSL在Xampp中工作 - 访问禁止错误

DL1*_*984 5 php apache xampp ssl https

我试图让Xampp在https中工作,但我遇到了一些问题.

到目前为止我做了什么:

  • mod_ssl.so已加载
  • php_openssl.dll已加载
  • httpd-ssl.conf中的DocumentRoot已从C:/ xampp/htdocs更改为C:/ xampp /,因为这是我站点的所有目录所在的位置.

我是否需要在httpd-ssl.conf中更改服务器名称?

编辑:我需要在端口443和80上的httpd-vhosts.conf中添加虚拟主机吗?另外,Xampp是否附带内置SSL证书等?

小智 0

我认为最好的方法是为您正在开发的每个项目创建一个VirtualHost。\n否则,您将需要更改您当时正在开发的项目的 DocumentRoot。

\n\n

因此,您可以更改“httpd-vhosts.conf”文件并为端口 80 创建一个 VH,将所有请求重定向到端口 443 的 VH(如果您只想禁用 HTTP),如下所示:

\n\n

\xe2\x80\xa2 HTTP

\n\n
<VirtualHost *:80>\n    ServerName yoursite.your.domain\n    Redirect / https://yoursite.your.domain/\n</VirtualHost>\n
Run Code Online (Sandbox Code Playgroud)\n\n

\xe2\x80\xa2 HTTPS

\n\n
<VirtualHost *:443>\n    ServerName yoursite.your.domain:443\n\n    #in your case you\'re not using htdocs, so DocumentRoot be like\n    DocumentRoot "C:\\xampp\\yourproject" \n\n    <IfModule mod_headers.c>\n        Header set Access-Control-Allow-Origin "*"\n        Header always set Access-Control-Allow-Methods "POST, PUT, GET, DELETE, OPTIONS"\n        Header always set Access-Control-Allow-Headers "Content-Type"\n    </IfModule>\n\n    #the same here\n    <Directory  "C:\\xampp\\yourproject">\n        Options +Indexes +Includes +FollowSymLinks +MultiViews\n        AllowOverride All\n        Require all granted\n    </Directory>\n\n    #check your absolute path bellow\n    SSLEngine on\n    SSLCertificateFile "C:\\xampp\\apache\\conf\\ssl.crt\\server.crt"\n    SSLCertificateKeyFile "C:\\xampp\\apache\\conf\\ssl.key\\server.key"\n</VirtualHost>\n
Run Code Online (Sandbox Code Playgroud)\n\n

关于证书,我认为 XAMPP 实际上带有内置的 SSL 证书,但是,即使没有,您也可以使用他的工具生成它。你可以在互联网上看到很多关于这方面的教程。

\n