1

My linux server hosts 3 virtual hosts, example.com, example.net, and example.org, separately configured to listen on 192.168.1.90:80 and respond to the addresses, the root directories are different and configured well. But which ever site I try to access it always delivers example.com.

<VirtualHost lists.pirate-party.in:80>
DocumentRoot "/home/webmaster/www/PirateParty/wiki"
<Directory "/home/webmaster/www/PirateParty/wiki">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

<VirtualHost www.pirate-party.in:80>
DocumentRoot "/home/webmaster/www/PirateParty"
<Directory "/home/webmaster/www/PirateParty">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
4
  • Could you provide the configuration for your vhosts ?
    – mimipc
    Mar 13, 2013 at 19:59
  • pastebin.com/nNLJyUPY
    – BMC
    Mar 13, 2013 at 20:09
  • There might be a confusing in linking between sites-available and sites enabled directories. Could you possibly post the output of : ls -l /etc/apache2/sites-enabled ls -l /etc/apache2/sites-available
    – MelBurslan
    Mar 13, 2013 at 21:43
  • Why not put your config right here in the question? You do want an answer don't you?
    – dunxd
    Mar 14, 2013 at 11:31

1 Answer 1

3

You should use the ServerName directive. Please note the NameVirtualHost directive is mandatory, as mentioned by @Ladadadada.

(From Apache's documentation : http://httpd.apache.org/docs/2.2/vhosts/name-based.html)

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>
4
  • Added and restarted. Still no change
    – BMC
    Mar 13, 2013 at 21:19
  • What's the output of the restart command ?
    – mimipc
    Mar 13, 2013 at 21:31
  • You might want to mention that the NameVirtualHost directive is required for name-based virtual hosts rather than just putting it in the example config without mentioning it.
    – Ladadadada
    Mar 15, 2013 at 10:16
  • I edited my post ;)
    – mimipc
    Mar 15, 2013 at 12:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .