1

I have my httpd.conf on fedora 8 that I am setting the virtual host file. Here is what I have:

DocumentRoot "/var/www/html"
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

then below I am trying to setup a vhost to have multiple sites on the server:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName kadence.tv
DocumentRoot /var/www/html/
</VirtualHost>

<VirtualHost *:80>
ServerName nacc.biz
DocumentRoot /var/www/html/nacc/
</VirtualHost>

also in the /var/www/html/ directory I have the index.php file for the kadence site...when I do to either site I get the index for the kadence site...any ideas what I am doing wrong

EDIT the full contents of my httpd configuration file are here.

4
  • There is not much to go by here, can we get the entire section posted please.
    – Jacob
    Jan 30, 2011 at 19:31
  • can you post the messages that you get in your log files when you access each site please.
    – user9517
    Jan 30, 2011 at 19:46
  • Question duplicated here: serverfault.com/questions/228892/… Jan 30, 2011 at 19:50
  • @jacob i posted my entire vhost in the link pastie.org/1512536 and if you scroll to the bottom you will see the NameVirtualHost section and the problem is regardless of whichever address i go to nacc.biz or kadence i get the kadence site... Jan 30, 2011 at 19:59

2 Answers 2

4

If the name you're using doesn't match one of the virtualhost sections, it will default to using the first one. My guess would be that you're accessing www.nacc.biz. The www is significant. The name has to match exactly. Since apache doesn't have a virtualhost section for www.nacc.biz, it is using the first one (kadence.tv) as the default.

Take a look at the ServerAlias directive, and use it to specify all of the server names you expect to use.

1
1

1 Check active NameVirtualHost. Open /etc/apache2/ports.conf file:

NameVirtualHost *:80

2 Check DNS

# ping app.local
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.

# ping john.app.local
PING localhost.localdomain (127.0.0.1) 56(84) bytes of data.

3 Check Apache config(/etc/apache2/sites-enabled/000-default):

<VirtualHost *:80>
        ServerName app.local
        DocumentRoot /var/www
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>

<VirtualHost *:80>
        ServerName john.app.local
        DocumentRoot /var/www/john
</VirtualHost>

$ sudo apache2ctl configtest
Syntax OK

$ sudo  apache2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server app.local (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost app.local (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost john.app.local (/etc/apache2/sites-enabled/000-default:12)

4 Test Apache:

$ curl http://john.app.local
john
$ curl http://app.local
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
2
  • yes i have it posted in my question Jan 30, 2011 at 16:32
  • I tried that but i ran into errors like Stopping httpd: [FAILED] Starting httpd: Syntax error on line 982 of /etc/httpd/conf/httpd.conf: CustomLog takes two or three arguments, a file name, a custom log format string or format name, and an optional "env=" clause (see docs) Jan 30, 2011 at 17:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .