我刚刚在新的windows机器上安装了ApacheV2.4、PHP和MySQL。我对httpd.conf只做了几处修改。我包括httpd-vhosts.conf,它定义了2个自定义站点(我从其中删除了默认的dummy站点),这两个站点都是WordPress站点。
其中一个WordPress站点没有数据库,当我转到htdocs根目录时,我会看到该站点的数据库连接错误。当我注释掉虚拟主机的DocumentRoot行时,目录清单再次出现。
下面是来自Directory-related的httpd.conf行(按顺序排列):
Define SRVROOT "C:/webserv/Apache24"
ServerRoot "${SRVROOT}"
AllowOverride none
Require all denied
DocumentRoot "${SRVROOT}/htdocs"
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
AllowOverride None
Options None
Require all granted造成问题的虚拟主机如下:
#gutenberg
DocumentRoot "${SRVROOT}/htdocs/gutenberg"
ServerName gutenberg.squarestarmedia.ie
ErrorLog "logs/gutenberg.localhost-error.log"(请注意,我正在使用我的hosts文件指向ServerName)。
我应该提到的是,我将htdocs目录从不同的驱动器中进行符号链接,但是在另一台windows机器上有一个非常相似的设置,它没有遇到相同的问题。
如何修复它,以便htdocs总是显示目录清单,即使子目录/虚拟主机有错误?
发布于 2022-03-05 10:20:50
在默认情况下,服务器在进入localhost根目录时服务于虚拟主机文件中最高级的站点。解决方案是为根htdocs目录本身包含一个虚拟主机。httpd-vhosts.conf:
#
DocumentRoot "${SRVROOT}/htdocs"
ServerName localhost
ErrorLog "logs/localhost-error.log"在虚拟主机文件的底部,localhost将返回一个目录,列出了任何情况。
https://serverfault.com/questions/1095243
复制相似问题