I'm trying to configure Apache as an in-network webserver, and am using the sites-available/sites-enabled feature as opposed to just static vhost files. I set up a couple VirtualHosts, all with a unique DocumentRoot, however request for all the VirtualHosts just serve up the "It's Working!" default file. I can't for the life of me figure out why it won't serve the content out of the correct directory. Here's the contents of the virtualhost directive files, let me know if I need to post more.
default
(note that apache renames this to 000-default
in sites-enabled, so it's not an ordering issue)
NameVirtualHost *:80
ServerName emp
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName emp
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
billmed
<VirtualHost *:80>
ServerName billmed.emp
ServerRoot /home/empression/Projects/billmed/web/httpdocs
<Directory "/home/empression/Projects/billmed/web/httpdocs">
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
Note that I have DNS zones for both emp
and billmed.emp
, as well as entries in /etc/hosts. My ultimate goal is to set up this machine as an in-house webserver with a custom tld (emp), but progress has been pretty slow.
Some more info
/etc/hosts
entries
#custom-sites
192.168.1.100 emp
192.168.1.100 billmed.emp
ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
#NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
ls -l sites-enabled
empression@empression-server1:/etc/apache2/sites-available$ ls -l ../sites-enabled/
total 0
lrwxrwxrwx 1 root root 26 2010-05-22 12:36 000-default -> ../sites-available/default
lrwxrwxrwx 1 root root 26 2010-05-22 13:33 billmed -> ../sites-available/billmed
Update 2010-06-16
I wasn't able to work on this for a few weeks, but I have tried all the solutions posted below as of now, and am still unable to fix the problem so I have added a bounty.
Update
Here's the output of apache2ctl -t -D DUMP_VHOSTS
empression@empression-server1:~$ apache2ctl -t -D DUMP_VHOSTS
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
[Mon Jul 12 14:29:01 2010] [warn] NameVirtualHost 127.0.0.1:80 has no VirtualHosts
VirtualHost configuration:
192.168.1.100:80 is a NameVirtualHost
default server billmed.emp (/etc/apache2/sites-enabled/billmed:1)
port 80 namevhost billmed.emp (/etc/apache2/sites-enabled/billmed:1)
Syntax OK
In virtual host definition file, correct the line below.
ServerRoot /home/empression/Projects/billmed/web/httpdocs
toDocumentRoot /home/empression/Projects/billmed/web/httpdocs
Use DocumentRoot directive to serve virtualhost. here is the link for more information http://httpd.apache.org/docs/2.2/mod/core.html
Update your virtualhost definition (/etc/apache2/sites-enabled/billmed) as following,
@yasin is correct; you need to have your VirtualHosts specify a DocumentRoot ('...the directory from which httpd will serve files...')not a ServerRoot ('...the directory in which the server lives. Typically it will contain the subdirectories conf/ and logs/....')
There might be another problem also, but that part is definitely wrong.
What is your mapping in
/etc/hosts
or in DNS configuration ? Try replacing*
with127.0.0.1
I mean<VirtaulHost 127.0.0.1:80>
andNameVirtualHost 127.0.0.1:80
. What is in your/etc/apache2/ports.conf
? Check if all symlinks are in place. for instance:/etc/apache2/sites-enabled/<yoursite.emp>
EDIT:
Try this: In
ports.conf
:Then in
000-default
:<VirtualHost 127.0.0.1:80>
Inbillmed
:<VirtualHost 192.168.1.100:80
I would add mask rather than concrete IP to the host file:
Change the ServerRoot to DocumentRoot in billmed file.
Add/Move your billmed vhost config in /etc/apache2/sites-available/.
Then enable the billmed vhost like this:
Restart apache:
Edit: changed a2enmod into a2ensite, stupid typo : )
Since it looks like you've tried everything else, make sure that you're including the sites-enabled folder from your main apache configuration file.
Also, if you disable everything but the billmed virtual host, can you get it to server files from that directory?
Are there any Alias directives which point / to /var/www that are in the global config as opposed to being inside a virtualhost section?
NameVirtualHost is commented out.
If you are setting up containers for each, and using ServerName/ServerAlias, you'll need to uncomment that, restart apache.
You HUP'd apache after creating the new site file, so that the running daemon re-read its config?