Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
share|improve this question
1  
Weird question perhaps, but is there actually a line Include sites-enabled/ in apache.conf / httpd.conf? –  Wrikken Jun 17 '10 at 0:14
    
Can you send dump of "apache2ctl -t -D DUMP_VHOSTS" command ? Maybe we are really missing something important. –  risyasin Jun 21 '10 at 16:12
    
i've updated my previous answer. –  risyasin Jul 20 '10 at 19:37
add comment

9 Answers 9

In virtual host definition file, correct the line below.

ServerRoot /home/empression/Projects/billmed/web/httpdocs to DocumentRoot /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,

<VirtualHost *:80>
 ServerName billmed.emp
 DocumentRoot /home/empression/Projects/billmed/web/httpdocs

 <Directory "/home/empression/Projects/billmed/web/httpdocs">
  Order Allow,Deny
  Allow from All
 </Directory>
</VirtualHost>
share|improve this answer
    
I added the output of apache2ctl -t -D DUMP_VHOSTS, see my updated post –  tj111 Jul 12 '10 at 18:40
add comment

@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.

share|improve this answer
add comment

What is your mapping in /etc/hosts or in DNS configuration ? Try replacing * with 127.0.0.1 I mean <VirtaulHost 127.0.0.1:80> and NameVirtualHost 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:

NameVirtualHost 127.0.0.1:80
Listen 127.0.0.1:80

NameVirtualHost 192.168.1.100:80
Listen 192.168.1.100:80

Then in 000-default: <VirtualHost 127.0.0.1:80> In billmed: <VirtualHost 192.168.1.100:80

share|improve this answer
1  
Thanks, see me edit. Also, would using a statically typed IP in the VirtualHost directive really help? –  tj111 May 22 '10 at 18:44
1  
I have similar configuration. It works. It is different from yours only in using IP addresses in ports.conf, VirtualHost and NameVirtualHost –  Casual Coder May 22 '10 at 19:11
    
I changed every instance of *:80 to 127.0.0.1:80 and still have the same results. :( –  tj111 May 22 '10 at 19:18
    
ok. look at my EDIT. –  Casual Coder May 22 '10 at 19:19
    
Ugh, I figured having unique IPs would force it serve different content. Nothing. There must be something I'm missing here. –  tj111 May 22 '10 at 19:43
show 1 more comment

I would add mask rather than concrete IP to the host file:

#/etc/hosts/

# custom-sites
127.0.0.1 emp
127.0.0.1 billmed.emp
share|improve this answer
add comment

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:

sudo a2ensite billmed

Restart apache:

sudo service apache2 restart

Edit: changed a2enmod into a2ensite, stupid typo : )

share|improve this answer
1  
that should be a2ensite (to enable a site), not a2enmod (to enable a module) –  Brian Jun 21 '10 at 16:17
    
thanks brian! typo... –  Weboide Jun 23 '10 at 1:17
add comment

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?

share|improve this answer
add comment

Are there any Alias directives which point / to /var/www that are in the global config as opposed to being inside a virtualhost section?

share|improve this answer
    
No, I grepped all the config files and there are no Aliases for / nor any that point to /var/www/. –  tj111 Jun 16 '10 at 18:55
add comment

NameVirtualHost is commented out.

If you are setting up containers for each, and using ServerName/ServerAlias, you'll need to uncomment that, restart apache.

share|improve this answer
add comment

You HUP'd apache after creating the new site file, so that the running daemon re-read its config?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.