Apache virtual hosts

Discuss Applications

Apache virtual hosts

Postby cdhgold » Sun Feb 08, 2004 8:51 am

I am trying to add a virtual host to my apache web server. I have added the following lines to my httpd.conf file and it is still not working. The 2nd site triplecandb.com comes up but shows the primary web site. System is running Suse 9.0

NameVirtualHost my static ip here

<VirtualHost www.addicted2tech.com>
ServerName jose.addicted2tech
DocumentRoot /srv/www/htdocs
</VirtualHost>

<VirtualHost www.triplecandb.com>
ServerName jose.addicted2tech
DocumentRoot /srv/www/htdocs/triplecandb
</VirtualHost>

Thanks Chris
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Postby Void Main » Sun Feb 08, 2004 9:01 am

Did you reload or restart Apache?
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby cdhgold » Sun Feb 08, 2004 10:02 am

restarted apache
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Postby Void Main » Sun Feb 08, 2004 10:14 am

I don't think your "ServerName" variables are right. Did you mean to have a *.com at the end of them? That is "jose.addicted2tech" should be "jose.addicted2tech.com". And the servername is the same in both entries yet point to different directories. That doesn't make sense. You need a unique servername that resolves in DNS for each DocumentRoot directory. I can't believe I didn't see that the first time around.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby cdhgold » Sun Feb 08, 2004 10:29 am

here is my edited lines but i'm still getting triplecanb pulling up addicted2tech site

<VirtualHost www.addicted2tech.com>
ServerName www.addicted2tech.com
DocumentRoot /srv/www/htdocs
</VirtualHost>

<VirtualHost www.triplecandb.com>
ServerName www.triplecandb.com
DocumentRoot /srv/www/htdocs/triplecandb
</VirtualHost>

chris
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Postby Void Main » Sun Feb 08, 2004 10:35 am

The name in the <VirtualHost xxxx> should be the same on all entries, and should match what you have in your "NameVirtualHost" variable (if you have it set). And I notice one is a subdirectory of the other. I always keep them separate although that doesn't mean it won't work (I don't know).

e.g.

/srv/www/htdocs/site1
/srv/www/htdocs/site2

is how I do it.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby cdhgold » Sun Feb 08, 2004 10:42 am

here is what i have now. still same thing

<VirtualHost www.addicted2tech.com>
ServerName www.addicted2tech.com
DocumentRoot /srv/www/htdocs
</VirtualHost>

<VirtualHost www.addicted2tech.com>
ServerName www.triplecandb.com
DocumentRoot /srv/www/htdocs/triplecandb
</VirtualHost>

chris
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Postby Void Main » Sun Feb 08, 2004 11:01 am

Try creating a directory that is not a subdirectory of the other one with an index.html test file in it and point your second DocumentRoot directory to it. As I said, I don't think you have have nested DocumentRoot directories.
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby cdhgold » Sun Feb 08, 2004 11:23 am

here is my current config that is still giving the same result

<VirtualHost www.addicted2tech.com>
ServerName www.addicted2tech.com
DocumentRoot /srv/www/htdocs
</VirtualHost>

<VirtualHost www.addicted2tech.com>
ServerName www.triplecandb.com
DocumentRoot /srv/www/triplecandb
</VirtualHost>

one thing i don't understand is why is the <VirtualHost> entry have to be the same?

Chris
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Postby Void Main » Sun Feb 08, 2004 11:35 am

I'm not sure why they have to be the same but I am fairly certain they have to be, and it's how I've always done it, and it's how I've always seen it in all of the examples like:

http://httpd.apache.org/docs-2.0/vhosts/examples.html

Also, it matches what you have for "NameVirtualHost" right? And you did restart apache after each change right? You might try "*" for the NameVirutualHost and in each of the VirtualHost definition names like in the link example above. Personally I have an entry in my /etc/hosts that doesn't match any web site that might look like this:

192.168.1.1 myserver


and then I use the same name in my NameVirtualHost and my VirtualHost:

NameVirtualHost myserver

<VirtualHost myserver>
ServerName voidmain.is-a-geek.net
DocumentRoot /var/www/voidmain
...
...
...
</VirtualHost>

And here are a couple of examples of what I have used (or are using) on the void server:

http://voidmain.is-a-geek.net/files/configs/httpd.conf
http://voidmain.is-a-geek.net/files/configs/httpd.conf2

EDIT: Oh, and most importantly, your Apache server must be able to resolve the names you are using in your "ServerName" directives. Do an "nslookup www.addicted2tech.com", and "nslookup www.triplecandb.com".
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby cdhgold » Sun Feb 08, 2004 11:53 am

aaauuugggghhhhhh ..frustrating .. this is my current config that still is not working ..

NameVirtualHost *

<VirtualHost *>
ServerName www.addicted2tech.com
DocumentRoot /srv/www/htdocs
</VirtualHost>

<VirtualHost *>
ServerName www.triplecandb.com
DocumentRoot /srv/www/triplecandb
</VirtualHost>

any ideas and thanks for all your advice to this point
chris
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Postby Void Main » Sun Feb 08, 2004 11:57 am

Send me your "/etc/hosts", your "/etc/resolv.con", your "httpd.conf" (ftp) and also look in your server's error log for any indication of the problem. Also, what version of Apache are you using?
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby cdhgold » Sun Feb 08, 2004 12:10 pm

files are uploaded apache version is 2.0.48
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Postby Void Main » Sun Feb 08, 2004 12:16 pm

Is your server behind a firewall? Can you also upload the output from "/sbin/ifconfig" and "netstat -rn"?
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby cdhgold » Sun Feb 08, 2004 12:19 pm

server is behind my dsl router/firewall .. i will be happy to give you any access you want void i trust you and apprecaite your help will be uploading the output you request as soon as i submit this post

chris
User avatar
cdhgold
administrator
administrator
 
Posts: 382
Joined: Tue Mar 18, 2003 6:11 pm
Location: Texas

Next

Return to Applications

Who is online

Users browsing this forum: No registered users and 1 guest