[英]Apache 2.2 VirtualHosts URL not found
I'm hoping you can help.我希望你能帮忙。 I have an existing Apache 2.2 server which serves a website I maintain.
我有一个现有的 Apache 2.2 服务器,它为我维护的网站提供服务。 I am attempting to add additional websites for a colleague.
我正在尝试为同事添加其他网站。 Having done so, I get the following when I attempt to access the URL:
这样做后,当我尝试访问 URL 时,我得到以下信息:
Not Found The requested URL / was not found on this server.
Not Found 请求的 URL / 未在此服务器上找到。
Here's a summary of my httpd-vhosts.conf file.这是我的 httpd-vhosts.conf 文件的摘要。 I have three new, roughly identical, hosts that aren't working.
我有三个新的、大致相同的主机无法工作。 Only NDV and the default are working.
只有 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>
Based on the config above, this is what the server is seeing.根据上面的配置,这就是服务器所看到的。
$ 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
You seem to mix configuration approaches: 您似乎混合配置方法:
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>
This is the example from the Apache Docs regarding name based VHosts. 这是Apache Docs关于基于名称的VHost的示例。
I can see in your config VirtualHost without the * -> anycast.ns.cs.boeing.com:80 我可以在你的配置VirtualHost中看到没有* - > anycast.ns.cs.boeing.com:80
as well as VHosts without a server name like ServerAlias ntpm-application-01.ns.cs.boeing.com which has an alias, but no name. 以及没有像ServerAlias ntpm-application-01.ns.cs.boeing.com这样的服务器名称的VHost,它有一个别名但没有名字。
I would start to even out the configurations like in the example and then try if the apache is more happy with that. 我会开始平衡配置中的配置,然后尝试apache对此更满意。
In short: Make sure each of you entries have *:80 and a server name. 简而言之:确保每个条目都有*:80和服务器名称。
Edit: This config is not tested but might work for you 编辑:此配置未经过测试,但可能适合您
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>
My advise is to open and read all the logs that apache generates. 我的建议是打开并读取apache生成的所有日志。 That will give you a clue of where the problem lies.
这将为您提供问题所在的线索。 I read the log at
"/private/var/log/apache2/error_log"
in a mac and found my clue: DocumentRoot [/path/to/rootdir] does not exist.
我在mac中读取了
"/private/var/log/apache2/error_log"
中的"/private/var/log/apache2/error_log"
,发现了我的线索: DocumentRoot [/path/to/rootdir] does not exist.
I opened the vhost file and found out that instead of encapsulating the root directory in double quotes I had used other characters that seemed like double quotes. 我打开了vhost文件,发现不是用双引号封装根目录,而是使用了其他似乎是双引号的字符。 I replaced them by the real double quotes, restarted apache and then the error was gone.
我用真正的双引号替换它们,重新启动apache然后错误消失了。
对我有用的是卸载和升级(在我的情况下为 Wampserver)您正在使用的软件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.