Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I need to create virtualhost with name "virtualhost_name". To access it with http://virtualhost_name

I have a pattern:

<VirtualHost *:80>
    ServerAdmin jan@novak.cz
    DocumentRoot "path"
    ServerName Name_of_server
    ErrorLog "logs/error.log"
    CustomLog "logs/log.log" common

Where should I write the name?

share|improve this question

migrated from stackoverflow.com Feb 6 '12 at 12:20

This question came from our site for professional and enthusiast programmers.

ServerName, obviously... –  Juicy Scripter Feb 6 '12 at 12:12

1 Answer 1

There are two places that you can write (you can use both of them):

  • ServerName: is the "internal" name of the vhost. It is not necessary the full qualified domain name. Just "myvhost" could be ok. Of course you can use the full name like "myvhost.example.com".
  • ServerAlias: is other names. It is useful when you want multiple domain names for the same vhost.

For example: you have a website that you want to host both example.com and example.net:

ServerName example
ServerAlias example.com example.net www.example.com www.example.net
share|improve this answer
Fully Qualified Domain Name explained: en.wikipedia.org/wiki/Fully_qualified_domain_name –  toomanyairmiles Feb 6 '12 at 14:17
Thanks for the link. Of course, sort name or FQDN in ServerName and ServerAlias, there is no rule, however I always use as in the code above. One "principle" domain and many aliases. –  jcisio Feb 6 '12 at 14:45
I just wanted to clear up the terminology... –  toomanyairmiles Feb 6 '12 at 14:50
ServerName should not be an internal name, it should be the/a name as used by clients. It will be used for generating self-referential URLs. –  covener Feb 25 '12 at 14:27
If you are on windows you may want to add the virtual host name to your hosts file system32/etc/hosts –  Anagio Mar 7 '12 at 14:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.