gpt4 book ai didi

php - 如何在 localhost 中为 XAMPP 创建有效的 SSL

转载 作者:行者123 更新时间:2023-12-04 22:34:36 27 4
gpt4 key购买 nike

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












我们不允许在 Stack Overflow 上提出有关通用计算硬件和软件的问题。您可以编辑问题,使其成为 on-topic对于堆栈溢出。


1年前关闭。


社区在 2 个月前审查了是否重新打开此问题并将其关闭:

原始关闭原因未解决






Improve this question




如何在我的 中使用安全连接 ( SSL ) XAMPP 在 window 里?
打开 localhost 页面时出现以下错误:

connection not secure

最佳答案

在我的 XAMPP 安装中,我基本上对我管理的所有站点都有一个克隆。并且所有这些(当然)都使用 SSL/HTTPS。
enter image description here
这是分步指南:
在这一步中,我们将装箱 SSL并设置“site.test”网站。
enter image description here
1. 导航到 XAMPP 中的 Apache 目录。
在常规安装中,它位于 C:\xampp\apache 中。
enter image description here
2. 在该页面中创建一个文件夹。
这是我们将存储我们的证书的地方。在本例中,我将创建“crt”文件夹。所以我们会有C:\xampp\apache\crt enter image description here
3. 添加这个文件。

  • cert.conf
  • make-cert.bat

  • enter image description here
    4. 编辑 cert.conf 并运行 make-cert.bat
    更改 {{域}} 使用我们要使用的域的文本,在本例中为 站点测试 并保存。
    双击 make-cert.bat 并在出现提示时输入域 site.test。并且只需输入其他问题,因为我们已经从 cert.conf 设置了默认值。
    enter image description here

    Note: I don’t know how to do text replace in .bat script, if you do, let me know in the comment how to do it and I will update make-cert.bat to automatically replace the {{DOMAIN}} with the domain input.


    enter image description here
    5.在windows中安装证书。
    之后,您将看到创建的 site.test 文件夹。在那个文件夹中,我们将有 服务器.crt server.key .这是我们的 SSL 证书。
    双击 服务器.crt 在 Windows 上安装它,以便 Windows 可以信任它。
    enter image description here
    然后选择 本地机 作为商店位置。
    enter image description here
    然后选择“ 将所有证书放入以下存储 ”,然后点击 浏览 并选择受信任的根证书颁发机构。
    enter image description here
    点击 下一个 完成 .
    现在此证书已在 Windows 中安装并受信任。接下来是如何在 XAMPP 中使用这个证书。
    enter image description here
    6.在Windows主机中添加站点
  • 以管理员身份打开记事本。
  • 编辑 C:\Windows\System32\drivers\etc\hosts (文件没有分机)
  • 在新行中添加:
  • 127.0.0.1 site.test
    这将告诉 Windows 加载 XAMPP 当我们访问 http://site.test您可以尝试,它将显示 XAMPP 仪表板页面。
    enter image description here
    7. 在 XAMPP conf 中添加站点。
    我们需要为这个域启用 SSL 并让 XAMPP 知道我们在哪里存储 SSL 证书。所以我们需要编辑 C:\xampp\apache\conf\extra\httpd-xampp.conf并在底部添加此代码:
     ## site.test
    <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>
    之后,您需要在 XAMPP 中重新启动 Apache。很简单,打开XAMPP控制面板和 停止并重新 开始 Apache 模块。

    Tips: In XAMPP conf, as you can see you can change the domain root directory if needed. Eg. as sub-dir in htdocs.


    enter image description here
    8. 重新启动浏览器并完成!
    这是加载证书所必需的。并在浏览器上访问该域,您将看到绿色锁!
    enter image description here
    enter image description here
    我希望这个教程是有用的!
    来源: https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/

    关于php - 如何在 localhost 中为 XAMPP 创建有效的 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64800565/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com