我希望你能提供帮助。我有一个现有的Apache 2.2服务器,它服务于我维护的网站。我正在尝试为同事添加其他网站。完成后,当我尝试访问URL时,我得到以下内容:
未找到此服务器上找不到请求的URL。
以下是我的httpd-vhosts.conf文件的摘要。我有三个新的,大致相同的主机不工作。只有NDV和默认值正常工作。
NameVirtualHost *:80
<VirtualHost anycast.ns.cs.boeing.com:80>
ServerName anycast.ns.cs.boeing.com
ServerAdmin aodhan.hoffman@boeing.com
DocumentRoot "/opt/www/anycast"
ScriptAlias /cgi-bin "/opt/www/anycast/cgi-bin/"
ErrorLog "logs/grant_error_log"
CustomLog "logs/grant_access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin aodhan.hoffman@boeing.com
DocumentRoot "/opt/httpd/manual"
ServerAlias ntpm-application-01.ns.cs.boeing.com
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin aodhan.hoffman@boeing.com
DocumentRoot "/opt/www/ndv/html"
ServerName ndv.web.boeing.com
ScriptAlias /cgi-bin/ "/opt/www/ndv/cgi-bin/"
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
</VirtualHost>
<Directory "/opt/www/ndv/html/" >
Options Indexes FollowSymLinks Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Order allow,deny
Allow from all
</Directory>
<Directory "/opt/www/anycast/html/" >
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
根据上面的配置,这就是服务器所看到的。
$ sudo bin/apachectl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server ntpm-application-01.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:30)
port 80 namevhost ntpm-application-01.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:30)
port 80 namevhost ndv.web.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:39)
port 80 namevhost anycast.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:48)
port 80 namevhost ntpget.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:60)
port 80 namevhost dnsdig.ns.cs.boeing.com (/opt/httpd/conf/extra/httpd-vhosts.conf:70)
Syntax OK
答案 0 :(得分:2)
您似乎混合了配置方法:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
这是Apache Docs关于基于名称的VHosts的示例。
我可以在配置VirtualHost中看到没有* - &gt; anycast.ns.cs.boeing.com:80
以及没有像ServerAlias ntpm-application-01.ns.cs.boeing.com这样的服务器名称的VHost 它有一个别名,但没有名字。
我会开始按照示例中的配置进行操作,然后尝试apache是否对此更满意。
简而言之:确保每个条目都有*:80和服务器名称。
编辑:此配置未经过测试但可能适合您
NameVirtualHost *:80
<VirtualHost *:80>
ServerName anycast.ns.cs.boeing.com
ServerAdmin aodhan.hoffman@boeing.com
DocumentRoot "/opt/www/anycast/html"
ScriptAlias /cgi-bin "/opt/www/anycast/cgi-bin/"
ErrorLog "logs/grant_error_log"
CustomLog "logs/grant_access_log" common
<Directory "/opt/www/anycast/html/" >
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ntpm-application-01.ns.cs.boeing.com
ServerAdmin aodhan.hoffman@boeing.com
DocumentRoot "/opt/httpd/manual"
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerName ndv.web.boeing.com
ServerAdmin aodhan.hoffman@boeing.com
DocumentRoot "/opt/www/ndv/html"
ScriptAlias /cgi-bin/ "/opt/www/ndv/cgi-bin/"
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
<Directory "/opt/www/ndv/html/" >
Options Indexes FollowSymLinks Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
答案 1 :(得分:0)
我的建议是打开并读取apache生成的所有日志。这将为您提供问题所在的线索。我在Mac中的"/private/var/log/apache2/error_log"
阅读了日志,发现了我的线索:DocumentRoot [/path/to/rootdir] does not exist.
我打开了vhost文件,发现不是用双引号封装根目录,而是使用了其他似乎是双引号的字符。我用真正的双引号替换它们,重新启动apache然后错误就消失了。