为什么我的虚拟端口链接到apache中的原始端口?

为什么我的虚拟端口链接到apache中的原始端口?

我正在尝试创建两个端口 80 和 81 来在我的计算机上呈现不同的文件。为此,我创建了一个虚拟主机。我的 httpd-vhost.conf 如下:

<VirtualHost *:81>
    ServerAdmin [email protected]
    DocumentRoot "D:\Softwear\Apache\httpd-2.4.23-win64-VC14\Apache24\htdocs\2"
    ServerName dummy-host.example.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "logs/dummy-host.example.com-error.log"
    CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>


<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "D:\Softwear\Apache\httpd-2.4.23-win64-VC14\Apache24\htdocs"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

在我的 httpd.conf 文件中,我在 Listen 80 行下面添加了 Listen 81。问题是 localhost:80 和 localhost:81 都引用了 localhost:80 的位置。

当我运行 httpd.exe -SI 时,没有提到 81 端口:

D:\Softwear\Apache\httpd-2.4.23-win64-VC14\Apache24\bin>httpd.exe -S
VirtualHost configuration:
ServerRoot: "D:/Softwear/Apache/httpd-2.4.23-win64-VC14/Apache24"
Main DocumentRoot: "D:/Softwear/Apache/httpd-2.4.23-win64-VC14/Apache24/htdocs"
Main ErrorLog: "D:/Softwear/Apache/httpd-2.4.23-win64-VC14/Apache24/logs/error.log"
Mutex default: dir="D:/Softwear/Apache/httpd-2.4.23-win64-VC14/Apache24/logs/" mechanism=default
PidFile: "D:/Softwear/Apache/httpd-2.4.23-win64-VC14/Apache24/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG

答案1

未包含包含虚拟主机的文件,否则“httpd -S”会有额外的输出

您的 ServerRoot 是“D:/Softwear/Apache/httpd-2.4.23-win64-VC14/Apache24”,因此默认配置文件将是“D:/Softwear/Apache/httpd-2.4.23-win64-VC14/Apache24/conf/httpd.conf”

查看文件,“httpd-vhost.conf”应该包含在内。可能它仍然被注释掉了?

相关内容