Reputation: 1019
I am having a slight apache problem. It's probably something so minor that I am just over looking it. This is the scenario. I have an Ubuntu 10.04 server setup with 2 websites. Before all of this, I had one site and I accessed it via the IP address. I just added a second site, this one with a domain name, and I created a new file in the sites-available dir. with a link to the sites-enabled dir.
The first site (the one I accessed via IP) config looks something like this:
#Default
<VirtualHost *:80>
DocumentRoot /var/www
......etc
Then the other config is something like this:
#Secondary
<VirtualHost TheDomainName.com:80>
DocumentRoot /var/www/thedomainname
.......etc
If you guys need me to post the full config files I will. Why does the request for the IP address fall through to the DomainName config? Is it because they are identical IP addresses? How do I differentiate between the two?
If I try to set the ip address on the first "Default" config instead of "*", this site only works and I can never get to the other "Secondary" site.
Thanks.
Upvotes: 0
Views: 2032
Reputation: 146460
Different sites cannot share IP and port combination unless you use name based virtual hosts. The example from the manual is this:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>
When you use this feature, unknown domain names map to the first <VirtualHost>
found in your configuration.
Upvotes: 1
Reputation: 2870
For site1:
<VirtualHost *:80>
ServerName oink.domain.com
DocumentRoot /var/www
...
For site2:
<VirtualHost *:80>
ServerName blah.domain.com
DocumentRoot /var/www/thedomainname
...
Upvotes: 0
Reputation: 1958
Are you using ServerName and ServerAlias in your virtual host directive?
<VirtualHost *:80>
ServerName www.domain.com
ServerAlias domain.com domain.net www.domain.net
The other thing, and you are probably doing this, but restarting apache after making changes
httpd restart
(or something similar .. /etc/init.d/apache2 restart or lighttpd if you are using that)
Upvotes: 1