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
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>
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.
What worked for me is uninstalling and upgrading (in my case Wampserver) the software that you're using.
Related
I want any domain to point a CNAME on my vhosts for that i use
ServerAlias *
in my vhosts but it only works with one vhost if I add it in both the CNAME pointed to the second vhost serves the contented from the first vhost.
e.g:
1st: files.domain.com CNAME to files.example.com
2nd: r.domain.com CNAME to r.example.com
but second one is also serving files.example.com
My httpd.conf has these two vhosts
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot /var/www/files.example.com
ServerName files.example.com
ErrorLog /var/www/files.example.com/logs/error_log
CustomLog /var/www/files.example.com/logs/custom_log common
<Directory "/var/www/files.example.com">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot /var/www/r.example.com
ServerName r.example.com
ErrorLog /var/www/r.example.com/logs/error_log
CustomLog /var/www/r.example.com/logs/custom_log common
<Directory "/var/www/r.example.com">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This may not be directly related but it could be of help to others: you can actually put many aliases in the same virtual host entry (in my case for the same domain):
ServerName example.com
ServerAlias mail.example.com files.example.com r.example.com
And be sure to include all these as server-aliases also while creating an SSL Certificate for the domain.
You have to add ServerAlias lines
below ServerName files.example.com add ServerAlias files.domain.com
and below ServerName r.example.com add ServerAlias r.domain.com
In your case apache uses files.example.com as default vhost, because it is first one.
I solved this problem by setting a dedicated ip on the vhost where I want the ServerAlias to be * and it worked
<VirtualHost 192.168.1.55:80>
ServerAdmin admin#example.com
DocumentRoot /var/www/r.example.com
ServerName r.example.com
ServerAlias *
ErrorLog /var/www/r.example.com/logs/error_log
CustomLog /var/www/r.example.com/logs/custom_log common
<Directory "/var/www/r.example.com">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have defined two VirtualHosts on Apache, and the problem is, one of them overrides the other one. i.e. when I try to reach the second address, the first one shows up.
Here is my first config:
ServerName www.example1.com
DocumentRoot /server/sites/example1
<VirtualHost *:80>
ServerAdmin admin#example1.com
DocumentRoot /server/sites/example1
ServerAlias example1.com
<Directory /server/sites/example1/>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And the second:
ServerName www.example2.tv
DocumentRoot /server/sites/tv/public/
<VirtualHost *:80>
ServerAdmin admin#example2.tv
DocumentRoot /server/sites/tv/public
<Directory /srver/sites/tv/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
When I load www.example2.tv, it still shows www.example1.com content.
example1 is written in PHP and example2 is Ruby on Rails.
You need to have the ServerName directive inside the VirtualHost configuration i.e.:
<VirtualHost *:80>
ServerName www.example2.tv
ServerAdmin admin#example2.tv
DocumentRoot /server/sites/tv/public
<Directory /server/sites/tv/public>
# This relaxes Apache security settings.
AllowOverride all
# MultiViews must be turned off.
Options -MultiViews
</Directory>
</VirtualHost>
You can examine your configured VirtualHosts using apachectl -S - this will print a list of all the configured VirtualHosts and their corresponding config files
So, I set up two virtual hosts on my apache and now, I can't access the server via localhost anymore.
Here's my vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#serv.net.local
DocumentRoot "W:/www"
<Directory "W:/www/">
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
ServerName serv.net.local
ErrorLog "logs/serv.net.local-error.log"
CustomLog "logs/serv.net.local-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#symfony.net.local
DocumentRoot "W:/www/symfony/web"
<Directory "W:/www/symfony/web/">
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
ServerName symdev.net.local
ServerAlias symfony.net.local
ErrorLog "logs/symdev.net.local-error.log"
CustomLog "logs/symdev.net.local-access.log" common
</VirtualHost>
All domains are in my hosts-file and are properly resolved. But I can only access the second vHost and get a connection reset error when trying to access localhost or serv.net.local. Same for using 127.0.0.1...
Any ideas whats wrong with this config?
According to discussion in comments, VirtualHost DocumentRoot was not readable because it contained no index, and directory listing was disabled, so fixing it solved the issue.
I'm currently using name-based virtual host configuration, to server about 5 different websites from the same IP address, just like in the apache documentation:
<VirtualHost *:80>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
Is it possbile to have something like:
<VirtualHost *:80>
ServerName www.domain.tld/folderpath
DocumentRoot /www/software
</VirtualHost>
The webpages in this folder are using a different software stack, and I'd like to keep it nicely separate. I tried the method above but it didn't work.
It's not possible the way you show - a VirtualHost is always just a host. But you could use an Alias.
<VirtualHost *:80>
ServerName www.domain.tld
DocumentRoot /www/domain
Alias /folderpath /www/software
</VirtualHost>
Is it possible to have a different vhost for each application like that:
<VirtualHost *:80>
ServerName www.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.domain.tld
Alias otherApp /www/otherApp
</VirtualHost>
I add to the alias.conf file (on a windows machine).
Remember that if it outside the 'document root' path, you'll need permissions
<IfModule alias_module>
#### FolderPath ####
Alias /folderpath "E:/any/path/you/like"
<Directory "E:/any/path/you/like">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
#### Another ####
Alias /another "E:/another/different/path"
<Directory "E:/another/different/path">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</IfModule>
Can anyone direct me to a good tutorial on how to set up virtual hosts using Apache 2.2? Here's my situation:
I have Apache running on my laptop and I want two websites-- one on port 80 and one on port 8089. I want to access each site from the other computer on my network by entering the computer's IP address, such as http://192.168.1.102 and http://192.168.1.102:8089. Yet when I enter the second url, it directs me to the website running on port 80.
Thanks in advance for any help.
First you need to instruct Apache to listen on the ports you need:
Listen 80
Listen 8089
Second you need to tell it what to do with 80 and 8089 traffic:
<VirtualHost *:80>
DocumentRoot /website/site80
ServerName internet.dev
</VirtualHost>
<VirtualHost *:8089>
DocumentRoot /website/site8089
</VirtualHost>
Third you need to "allow" Apache to use those directories:
<Directory "C:/website/site80">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "C:/website/site8089">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Just have 2 virtual hosts defined like this, but with differeing DocumentRoots:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.somecompany.com
DocumentRoot "/docs/dummy-host.somecompany.com"
ServerName dummy-host.somecompany.com
ServerAlias www.dummy-host.somecompany.com
ErrorLog "logs/dummy-host.somecompany.com-error.log"
CustomLog "logs/dummy-host.somecompany.com-access.log" common
</VirtualHost>
<VirtualHost *:8089>
ServerAdmin webmaster#dummy-host.somecompany.com
DocumentRoot "/docs/dummy-host.somecompany.com"
ServerName dummy-host.somecompany.com
ServerAlias www.dummy-host.somecompany.com
ErrorLog "logs/dummy-host.somecompany.com-error.log"
CustomLog "logs/dummy-host.somecompany.com-access.log" common
</VirtualHost>