虚拟主机配置适用于 XAMPP 5.6.15 但不适用于 XAMPP 7.0.1

Virtualhosts config works on XAMPP 5.6.15 but not XAMPP 7.0.1

2x Windows 10 台最近全新安装的 Pro 计算机。 1 几周前的几天。我是不是忘记配置什么了?!

两者都在监听正确的端口。

代码如下所示:(我 100% 确定路径也指向正确的文件夹)

NameVirtualHost *

<VirtualHost *>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
</VirtualHost>

<VirtualHost *:81>
    DocumentRoot "Path1"
    ServerName project1.dev
    <Directory "Path1">
        Options all
        AllowOverride all
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:82>
    DocumentRoot "Path2"
    ServerName project2.dev
    <Directory "Path2">
        Options all
        AllowOverride all
        Allow from all
        Require all granted
    </Directory>
</VirtualHost>

localhost:80 仍然适用于两者,但如果我尝试使用每个项目的端口访问它们各自的页面,它只适用于最旧的安装。

只是说它无法访问页面没有错误,来自同一台机器的以太网或通过 LAN 和 WAN 访问。

我没主意了...谢谢你的时间。

编辑:我忘了提到 Apache 似乎没有记录对较新安装的访问尝试。如果我访问仪表板或 phpmyadmin,它会记录但如果我尝试使用项目网站的端口则不会。

Edit2:我已经使用 httpd -D DUMP_VHOSTS 确认两个虚拟主机都处于活动状态。所以现在的问题似乎是由于某种原因我无法简单地访问虚拟主机。某些东西阻止了我的浏览器和与它无关的 apache 之间的连接我是本地的还是联网的。

Edit3:重要更新 - 我在另一台计算机上尝试了 installint xampp 并进行了尝试,但仍然无法正常工作。但是在安装时我记得我正在安装最新版本 XAMPP 7.0.1。所以我在另一台计算机上安装了 XAMPP,但现在使用旧的 XAMPP 5.6.15 版本,该版本正在旧的 windows 安装上工作,猜猜看,它有效。所以问题与更新的 XAMPP 有关,可能与其他无关。我也会更新标题。

Edit4:现在我知道它与 XAMPP/Apache 有关,我回到虚拟主机配置,通过反复试验发现它与 Require all granted 有关,因为删除它或更改为 Require all denied 现在 returns 出现 403 错误访问被禁止!页面(因无法连接而得到改进)。由于所有建议修复 403 错误的页面都涉及 Require all granted 我将不得不继续挖掘。

Edit5:重要更新 - 我决定看看它是否与我的文件有关,所以我开始删除一些。删除我的 index.php 让事情再次发生,所以我深入挖掘并注意到,如果我删除了关于会话的代码,一切都会按预期加载。所以现在看来​​它是 PHP 7.0.1 处理会话的特定方式。

Edit6:好的,特别是 Session_start(); 破坏了一些东西。

这是 XAMPP 最新版本中的一个错误...

we have been checking the configuration of XAMPP and we found that the issue is related to the use_only_cookies variable that you can find in the Session's section of the php.ini file. Apache will crash if the use_only_cookies variable in the Session's section is set to 0 and everything is fine if it's set to 1.

http://php.net/manual/en/session.configuration.php#ini.session.use-only-cookies

We also checked that the use_strict_mode should be set to 1.

https://wiki.php.net/rfc/strict_sessions http://php.net/manual/en/session.configuration.php#ini.session.use-strict-mode

We'll include those changes in the next version of XAMPP with PHP 7. We are building the installers with the version 7.0.2 and we'll release them as soon as possible.