0

I'm hoping you can help. I have an existing Apache 2.2 server which serves a website I maintain. I am attempting to add additional websites for a colleague. Having done so, I get the following when I attempt to access the URL:

Not Found The requested URL / was not found on this server.

Here's a summary of my httpd-vhosts.conf file. I have three new, roughly identical, hosts that aren't working. Only NDV and the default are working.

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
oddhan
  • 3
  • 1
  • 1
  • 4

3 Answers3

2

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.

I can see in your config VirtualHost without the * -> 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.

I would start to even out the configurations like in the example and then try if the apache is more happy with that.

In short: Make sure each of you entries have *:80 and a server name.

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>
Kai Mattern
  • 3,090
  • 2
  • 34
  • 37
  • Thanks, I've evened out the config, it now looks like this but behaves no differently. ndv still works, but anycast simply returns 'URL not found'. Since I have indexes on I'd expect to see an auto-index, but instead it simply says '/' not found. It boggles. – oddhan Jul 19 '12 at 19:56
  • Thanks, but behaves no differently. NameVirtualHost *:80 ServerName anycast.domain.com ServerAdmin aodhan.hoffman@domain.com DocumentRoot "/opt/www/anycast" ScriptAlias /cgi-bin "/opt/www/anycast/cgi-bin/" ErrorLog "logs/grant_error_log" CustomLog "logs/grant_access_log" common Options Indexes FollowSymLinks Includes Order allow,deny Allow from all – oddhan Jul 19 '12 at 19:58
  • Uhm, just something I notice. Do quotes really work in a apache config? I have never seen that. – Kai Mattern Jul 19 '12 at 20:59
  • I guess quotes are ok, as you config seems ok for the webserver. I attached a reformatted one, that might work out for you. Please be aware that your document roots and directoy directive were pointing to different directories . and ./html and I would advise you to incormporate the directory entries within the VHOSTs. – Kai Mattern Jul 19 '12 at 21:13
  • And just one additional word: unless this thing is purely intranet: order allow,deny -> allow from all can be a very insecure thing. – Kai Mattern Jul 19 '12 at 21:16
1

My advise is to open and read all the logs that apache generates. 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.

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. I replaced them by the real double quotes, restarted apache and then the error was gone.

dev4life
  • 10,785
  • 6
  • 60
  • 73
0

What worked for me is uninstalling and upgrading (in my case Wampserver) the software that you're using.

  • Please improve your answer. Read https://stackoverflow.com/help/how-to-answer for more information. – nurchi Nov 19 '21 at 17:01