I’m trying to use the Apache included with SLES (close enough to OpenSuse I hope) to create a virtual host environment.
My default host, and default SSL virtual host, both work fine. My problem is when I add an additional vhost by editing the vhost.template and saving it as a .conf file I lose all of my sites. And adding a virtual host via Yast doesn’t work either.
Is there something unique about the SuSE setup that I’m not seeing?
For reference, my named vhost.conf file looks like this:
Allow from all
Allow from all
I’ve tried setting this up in various combinations, leaving out the default domain, since it seems to be included in the default-server.conf file.
Try change the <VirtualHost my.domain.org:80> to <VirtualHost !your IP here!:80> to use IP base virtual hosting.
ServerName directive should have different names for each virtual host declaration, and (I’m not shure about this) each vhost should point to different directory.
If domain name is correctly resolved to IP, you can use name instead of IP number, but it’s not the point. Point is your ServerName directive set to same hostname, and VirtualHost declarations are set for different hosts. The VirtualHost should contain the real host IP or name, and ServerName within VirtualHost tells Apache about virtual domain.
Here it is, with domains and IPs changed to protect the innocent.
[Fri Nov 07 23:51:06 2008] [warn] VirtualHost my.domain.org:80 overlaps with VirtualHost [Domain.org](http://www.domain.org:80), the first has precedence, perhaps you need a NameVirtualHost directive
[Fri Nov 07 23:51:06 2008] [warn] NameVirtualHost *:0 has no VirtualHosts
205.xxx.xxx.xxx:80 my.domain.org (/etc/apache2/vhosts.d/yast2_vhosts.conf:1)
When it’s in this state, none of our sites are accessable.
in /etc/apache2/listen.conf to activate virtual hosting. Any request that doesn’t match a virtualhost name maps to the first virtualhost read in by Apache. Therefore I normally put the default virtualhost spec in 000default.conf in /etc/apache2/vhosts.d. (It’s good practice to put one virtualhost per .conf file in that directory.) And I often make this default virtualhost serve very little, not even a front page, to feed the web vermin that just go scanning IP addresses for web apps with security holes.
Sometimes people mistakenly think it’s the line
that tells Apache what the vhost names are. It is not. It is in fact the line:
plus any ServerAlias lines. That VirtualHost line should be changed to
so that your virtualhost is active on all interfaces (including any secondary IP addresses, VPN addresses) as this is the normal case. Only when you want to restrict the virtualhost to certain addresses do you restrict it.