You are not logged in.

#1 2012-07-17 16:17:27

Ztjuh
Member
Registered: 2011-05-30
Posts: 58

[SOLVED] Apache Vhosts

I've setup my Apache today, but it doesn't work as expected.
When I go to http://ztjuh.supersik.net (the last one in the config file) it comes out in "/srv/http" instead of "/home/ztjuh/test". What is the mistake I made? I can't figure it out, it's like it doesn't find the last one in the config file.


File: /etc/httpd/conf/extra/httpd-vhosts.conf

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/srv/http"
</VirtualHost>

<VirtualHost *:80>
    ServerName ztjuh.zapto.org
    DocumentRoot "/home/ztjuh/public_html"
</VirtualHost>

<VirtualHost *:80>
    ServerName ztjuh.supersik.net
    DocumentRoot "/home/ztjuh/test"
</VirtualHost>

File: /etc/hosts

#<ip-address>   <hostname.domain.org>   <hostname>
127.0.0.1       localhost.localdomain   localhost arch
127.0.0.1       ztjuh.zapto.org
127.0.0.1       ztjuh.supersik.net
::1             localhost.localdomain   localhost

Last edited by Ztjuh (2013-03-02 14:49:29)

Offline

#2 2012-07-17 16:33:38

ebal
Member
From: Athens, Greece
Registered: 2009-05-26
Posts: 224
Website

Re: [SOLVED] Apache Vhosts

first change to debug from warn
second, try 127.0.0.13 in /etc/hosts & virtualhost and see whats happen

tail -f logs to catch any errors


https://balaskas.gr
Linux System Engineer - Registered Linux User #420129

Offline

#3 2012-07-17 17:05:43

Ztjuh
Member
Registered: 2011-05-30
Posts: 58

Re: [SOLVED] Apache Vhosts

I fixed it.

ServerName ztjuh.supersik.net

changed to

ServerName 192.168.0.150

in httpd.conf.

Thanks alot, because if you wouldn't have said about the debug thing I would never have looked in httpd.conf and see it!

Offline

#4 2012-07-17 17:08:31

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,229
Website

Re: [SOLVED] Apache Vhosts

iirc, the order of the vhosts is very important: the first one matches the request, and thus it is served.

More info: http://wiki.apache.org/httpd/CommonMisconfigurations/ - in short: the first has no serverName included, and thus is served as the default.

Offline

#5 2012-07-17 17:09:56

Ztjuh
Member
Registered: 2011-05-30
Posts: 58

Re: [SOLVED] Apache Vhosts

Yeah I already knew that, but because I set ztjuh.supersik.net to default in httpd.conf it served that one instead of the one in vhosts.conf!

Offline

Board footer

Powered by FluxBB