Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Apache virtual hosts configuration
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
milothurston
Apprentice
Apprentice


Joined: 01 May 2002
Posts: 231
Location: Oxford, England.

PostPosted: Sat May 27, 2006 9:36 pm    Post subject: Apache virtual hosts configuration Reply with quote

I'm setting up a server that should have two sites on it, using name-based virtual hosts. The relevant section of my httpd.conf file looks like this:
Code:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.default_site.org
DocumentRoot /var/www/vhosts/default
DirectoryIndex index.php index.html
</VirtualHost>

<VirtualHost *:80>
ServerName www.other_site.org
DocumentRoot /var/www/vhosts/other_site.org
DirectoryIndex index.php index.html
ErrorLog logs/other_site-error_log
CustomLog logs/other_site-access_log common
</VirtualHost>


There are two problems.
1. Any incoming traffic to www.other_site.org shows the index.html file in /var/www/vhosts/site1/htdocs.
2. The site2 logs are empty - everything goes into the default logs.

The docs at http://httpd.apache.org/docs-2.0/vhosts/ (if I've understood them) seem to suggest that I've got that config right, but the results suggest otherwise. Is there anything obvious that I've missed?
Back to top
View user's profile Send private message
ikaro
Advocate
Advocate


Joined: 14 Jul 2003
Posts: 2527
Location: Denmark

PostPosted: Sat May 27, 2006 11:04 pm    Post subject: Reply with quote

Hi there :)

Some background information:
In my box, the ip of machine (http://localhost) shows one site, while www.site.tld and www.site2.tld show diferent sites.
I also use test.site.tld and test.site2.tld in my setup.

Here are some working examples from my vhosts file:

Code:

NameVirtualHost *:80
<IfDefine DEFAULT_VHOST>
<VirtualHost *:80>
        ServerName xxx.xxx.xxx.xx
        ServerAlias xxx.xxx.xxx.xx
        DocumentRoot "/var/www/localhost/htdocs"
    <Directory "/var/www/localhost/htdocs">
        Options FollowSymLinks Indexes
        AllowOverride Indexes
        Order allow,deny
        Allow from all
    </Directory>

    <IfModule peruser.c>
        ServerEnvironment apache apache
        MinSpareProcessors 4
        MaxProcessors 20
    </IfModule>
</VirtualHost>
</IfDefine>


<VirtualHost *:80>
    ServerName www.site.tld
    ServerAlias fluxmod.dk
    DocumentRoot "/var/www/site.tld"
<Directory "/var/www/site.tld">
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>
    ErrorLog /var/www/site.tld/logfiles/error.log
    CustomLog /var/www/site.tld/logfiles/access.log combined
</VirtualHost>


<VirtualHost *:80>
    ServerName www.site.tld
    ServerAlias ikaro.dk
    DocumentRoot "/var/www/site.tld"
<Directory "/var/www/site.tld">
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>
    ErrorLog /var/www/site.tld/logfiles/error.log
    CustomLog /var/www/site.tld/logfiles/access.log combined
</VirtualHost>


<VirtualHost *:80>
    ServerName www.test.site.tld
    ServerAlias test.site.tld
    DocumentRoot "/var/www/www.test.site.tld"
<Directory "/var/www/test.site.tld/">
        AllowOverride All
        Order allow,deny
        Allow from all
</Directory>
    ErrorLog /var/www/test.site.tld/logfiles/error.log
    CustomLog /var/www/test.site.tld/logfiles/access.log combined
</VirtualHost>



Hope it helps :)
_________________
linux: #232767
Back to top
View user's profile Send private message
milothurston
Apprentice
Apprentice


Joined: 01 May 2002
Posts: 231
Location: Oxford, England.

PostPosted: Sun May 28, 2006 2:03 pm    Post subject: Reply with quote

Fixed now, thanks. Apparently an extra VirtualHost directive had crept in elsewhere in the httpd.conf file.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum