0

I want to serve more than one host name on a server on a specific port. Let's say namely;

example1.com, example2.com, example3.com, example4.com.

I have configured them as;

<VirtualHost example1.com:85>
    ServerName www.example1.com
    ServerAlias www.example1.com example1.com
    .
    .
    .
</VirtualHost>
<VirtualHost example2.com:85>
    ServerName www.example2.com
    ServerAlias www.example2.com example2.com
    .
    .
    .
</VirtualHost>
<VirtualHost example3.com:85>
    ServerName www.example3.com
    ServerAlias www.example3.com example3.com
    .
    .
    .
</VirtualHost>
<VirtualHost example4.com:85>
    ServerName www.example4.com
    ServerAlias www.example4.com example4.com
    .
    .
    .
</VirtualHost>

When I use this configuration, it recommands me to use NameVirtualHost and all sites goes to first one.

When I add NameVirtulHost to each one it says www.example2.com, www.example3.com and www.example4.com has no virtualhosts. And first one goes to correct one but the others goes to second one.

How can I do this configuration properly.

3
  • You only need one NameVirutalHost - NameVirtualHost *:80 in your main config should do the trick
    – arco444
    Jun 16, 2015 at 12:32
  • Can you be more spesific please? What exactly should I do? I am really very beginner about this issue :)
    – xxlali
    Jun 16, 2015 at 12:37
  • You said: When I add NameVirtulHost to each one I said: You only need one NameVirutalHost I can't be much clearer! Look at the example here
    – arco444
    Jun 16, 2015 at 12:58

1 Answer 1

0

Generally, you only need each virtualhost to have the argument *:80, one NameVirtualHost *:80, then ServerAlias/ServerName in each VirtualHost. Using a hostname in virtualhost causes all sorts of trouble.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.