【问题标题】:Enabling SSL with XAMPP使用 XAMPP 启用 SSL
【发布时间】:2011-08-13 16:07:55
【问题描述】:

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

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

我缺少什么设置?感谢您的帮助。

【问题讨论】:

  • 你的教程链接不是https,它教如何制作httpa

标签: ssl https xampp http-status-code-404


【解决方案1】:

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

只需将文档根目录更改为相同的根目录即可解决问题。

【讨论】:

  • 请记住,您还需要重新启动 Apache 以使这些更改生效(您可能需要分别使用 sudo /Applications/XAMPP/xamppfiles/xampp disablesslsudo /Applications/XAMPP/xamppfiles/xampp enablessl 禁用和重新启用 SSL 以使其正常工作)。
  • 不要忘记为 SSL 转发端口 443。希望对某人有所帮助=)
  • 这篇文章对我帮助很大,请不要忘记重启 chrome。 shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp
【解决方案2】:

您也可以像这样在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>

我想,如果您有多个项目并且需要在多个项目上使用 SSL,最好不要在 httpd-ssl.conf 中更改它

【讨论】:

  • 我按照您提到的相同步骤修改了 httpd-vhost.conf,因为我有多个域作为主机,例如 example.com example2.com example3.com 并且我已将 ssl 添加到 example2.com 但是它没有按预期工作。当我转到 example2.com 时,它会显示 example.com 网站。
【解决方案3】:

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

  1. G:\xampp\apache\conf\extra\httpd-ssl.conf"

  2. 搜索“DocumentRoot”文本。

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

【讨论】:

    【解决方案4】:

    在 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>
    

    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>
    

    确保正确给出 server.crt 和 server.key 路径,否则这将不起作用。

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

    # Virtual hosts
    Include etc/extra/httpd-vhosts.conf
    

    【讨论】:

      【解决方案5】:

      这里有更好的 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>
        
      5. 重启 Apache 和你的浏览器就完成了!

      【讨论】:

        【解决方案6】:

        如果您使用的是 Mac OS(catalina 或 mojave)并希望在 XAMPP for Mac 上启用 HTTPS/SSL,您需要启用虚拟主机并使用 XAMPP 中包含的默认证书。 在您的 httpd-vhosts.conf 文件中添加一个新的虚拟主机:

        <VirtualHost *:443>
            ServerAdmin webmaster@localhost.com
            DocumentRoot "/Users/your-user/your-site"
            ServerName your-site.local
            SSLEngine on
            SSLCertificateFile "etc/ssl.crt/server.crt" 
            SSLCertificateKeyFile "etc/ssl.key/server.key"
            <Directory "/Users/your-user/your-site">
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Require all granted
                Order allow,deny
                Allow from all
            </Directory>
        </VirtualHost>
        

        【讨论】:

          【解决方案7】:

          我终于让它在我自己托管的 xampp windows 10 服务器网站上运行。 IE。挂锁作为 ssl 出现。我从 2020 年 11 月开始使用 xampp 版本。

          1. 去了 certbot.eff.org。从他们的主页选择软件[apache]和系统[windows]。然后将下一页找到的 certbot 软件下载并安装到我的 C 盘中。

          2. 然后从命令行 [Windows 中的 cmd 开始,然后在打开 cmd 之前右键单击以管理员身份运行 cmd] 我从上面的 Certbot 页面输入了命令。 IE。导航到 system32-- C:\WINDOWS\system32> certbot certonly --standalone

          3. 然后按照提示输入我的域名。这在 C:\Certbot yourwebsitedomain 文件夹中创建了 cert1.pem 和 key1.pem 证书。 cmd 窗口会告诉你这些在哪里。

          4. 然后将它们的名称从 cert1.pem 更改为我的域名或更短的 +cert.pem 和相同的域名或更短的 +key.key。将它们分别复制到 C:\xampp\apache\ssl.crt 和 ssl.key 文件夹中。

          5. 然后对于 G:\xampp\apache\conf\extra\httpd-vhosts 输入以下内容:

          <VirtualHost *:443>
              DocumentRoot "G:/xampp/htdocs/yourwebsitedomainname.hopto.org/public/" ###NB My document root is public.  Yours may not be.  Or could have an index.php page before /public###
              ServerName yourwebsitedomainnamee.hopto.org 
              <Directory G:/xampp/htdocs/yourwebsitedomainname.hopto.org>
                  Options Indexes FollowSymLinks Includes ExecCGI
                  AllowOverride All
                  Require all granted
              </Directory>
              ErrorLog "G:/xampp/apache/logs/error.log"
              CustomLog "G:/xampp/apache/logs/access.log" common
              SSLEngine on
          SSLCertificateFile "G:\xampp\apache\conf\ssl.crt\abscert.pem"
          SSLCertificateKeyFile "G:\xampp\apache\conf\ssl.key\abskey.pem"
          </VirtualHost>  
               
          
          1. 然后导航到 G:\xampp\apache\conf\extra\httpd-ssl.conf 并按照上面的建议进行操作。在我阅读这篇文章之前,我已经错过了这重要的一步。谢谢! IE。输入了
          <VirtualHost _default_:443>
          DocumentRoot "G:/xampp/htdocs/yourwebsitedomainnamee.hopto.org/public/"
          ###NB My document root is public.  Yours may not be.  Or could have an index.php page before /public###
          SSLEngine on
          SSLCertificateFile "conf/ssl.crt/abscert.pem"
          SSLCertificateKeyFile "conf/ssl.key/abskey.pem"
          CustomLog "G:/xampp/apache/logs/ssl_request.log" \
                    "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
          </VirtualHost>  
          
          

          注1。我用www.noip.com注册了域名。 笔记2。而不是尝试让他们给我一个 ssl 证书,因为我无法让它工作,而是上面的工作。 Note3 我使用 noip DUC 软件使我的个人托管网站与 noip 保持同步。 注4。在 xampp 中进行每次更改后停止和启动 xampp 服务器非常重要。如果 xampp 由于某种原因失败,而不是启动 xampp consol,请尝试启动 xampp,因为这会给您带来问题,您可以修复错误。快速复制这些并粘贴到 note.txt 中。

          【讨论】:

            猜你喜欢
            • 2015-11-20
            • 2011-05-22
            • 2011-08-16
            • 2015-05-29
            • 2018-05-04
            • 2011-10-01
            • 2014-01-10
            • 2017-06-07
            • 2017-07-20
            相关资源
            最近更新 更多