You are not logged in.

#1 2010-05-12 12:53:25

martvefun
Member
From: The Internets
Registered: 2009-12-19
Posts: 180

[solved] [apache] more than one site

Hello,

I'm trying to configure my apache server to have more than a site at the same time.
my httpd.conf
with

...
ServerName localhost

<VirtualHost *:80>
    ServerName test
    DocumentRoot /srv/http/test
    <Directory /srv/http/test>
        Options FollowSymLinks MultiViews
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName wiki
    DocumentRoot /srv/http/wiki
    <Directory /srv/http/wiki>
        Options FollowSymLinks MultiViews
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>
...

both "test" and "wiki" are in my /etc/hosts but if I go to http://localhost, http://test or http://wiki, I arrive on the same page : the index.html in /srv/htpp/test

Why only the first one ?

Thank you

Last edited by martvefun (2010-05-22 09:21:52)


English is not my native language, sorry for the mistakes
Arch amd64, GNOME, Thinkpad

Offline

#2 2010-05-12 15:20:10

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: [solved] [apache] more than one site

Did you try usins http://localhost/wiki and http://localhost/test ?

Offline

#3 2010-05-12 15:41:25

kermana
Member
Registered: 2009-04-13
Posts: 60

Re: [solved] [apache] more than one site

If what you are trying to do is serve more than one site under only 1 ip, you either need to serve it under a directory as n0dix suggested (http://localhost/test ...etc), use a different port or bind virtualhosts to different domains. I am not sure if /etc/hosts entries would count as different domains smile You might need to setup a local dns server but it might as well be over kill. You should probably start reading read http://httpd.apache.org/docs/2.0/vhosts/examples.html if you haven't already. Don't take my words as a fact though, i am not a professional admin nor have experiance so might be wrong.

Edit: After some reasearch apperantly /etc/hosts should work as well ... no clue, sorry can't help

Edit 2: I just saw that you might need to set "UseCanonicalName Off" to make apache get the servernames from request headers.

Last edited by kermana (2010-05-12 16:25:47)

Offline

#4 2010-05-12 22:51:14

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,237
Website

Re: [solved] [apache] more than one site

/etc/hosts should work since the HTTP request will come to the server with a "Host: wiki" (for example) header.

You need to put "NameVirtualHost *:80" above your VHost definitions though.

Offline

#5 2010-05-13 00:55:22

davidm
Member
Registered: 2009-04-25
Posts: 371

Re: [solved] [apache] more than one site

Here's how I have my name based hosts set up (about 15 different sites for this server):

NameVirtualHost *:80

#
#
#
#

<VirtualHost *:80>
ServerAdmin webmaster@mysite.com
DocumentRoot /home/mysite/mysite.com
ServerName mysite.com
ServerAlias www.mysite.com
ErrorLog /var/log/httpd/mysite.com/error_log
CustomLog /var/log/httpd/mysite.com/access_log combined
</VirtualHost>

# other entries below this one.

It looks as if your issue is the lack of the "NameVirtualHost" as fukawi2 states.

Offline

#6 2010-05-13 09:28:45

martvefun
Member
From: The Internets
Registered: 2009-12-19
Posts: 180

Re: [solved] [apache] more than one site

Yes thanks it works smile


English is not my native language, sorry for the mistakes
Arch amd64, GNOME, Thinkpad

Offline

Board footer

Powered by FluxBB