Apache virtual hosts
Apache virtual hosts
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
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
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.
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
<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
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.
e.g.
/srv/www/htdocs/site1
/srv/www/htdocs/site2
is how I do it.
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
<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
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
<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
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".
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".
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
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