Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

i want to setup a virtual host to the url of with some port

e.g. my server name is

so i want to setup a subdomain on my server.where i should access the content of

what i tried :

<VirtualHost *>
  DocumentRoot ""


which is giving error

Warning: DocumentRoot [/etc/apache2/http:/] does not exist
share|improve this question

2 Answers 2

The DocumentRoot points to the folder in the local folder structure where the site is hosted, e.g. (on a linux system) /var/www/html/ The port number must be included in the VirtualHost definition. Therefore your VHost definition should rather look like:

<VirtualHost *:8001>
  DocumentRoot "/var/www/html/"


However, this will still require the users to enter into their browser. I suspect what you had in mind was actually more like a redirection. If the redirection needs to include a change of port (i.e. from 8001 to 80) then you either need to use a reverse proxy or a DNAT firewall.

Or, if the content that is to be made available under is located on the same server where is located, you could simply use a


redirection within the file system. However, in that case I wonder why you don't just point at the same location where gets its content from?

share|improve this answer
<VirtualHost *:8001> ServerName DocumentRoot "/var/www/html/" </VirtualHost> is not working how to use location tag ? –  Rahul Mehta May 17 '11 at 12:33
Well, where is the relevant content located, i.e. what is the DocumentRoot for the VHost running For the explanation on how to use the <Location> directive, read the Apache manual (I presume this is what you are using). –  wolfgangsz May 17 '11 at 12:42
the content of is coming from node.js server –  Rahul Mehta May 17 '11 at 12:44
@Rahul Are you setting up a production server? –  i.amniels May 17 '11 at 13:11
I am sorry, @Rahul, but your last comment doesn't make any sense to me whatsoever. Is the content on the same machine or not? And if yes, what is its location? –  wolfgangsz May 17 '11 at 13:33

The DocumentRoot directives describes the physical path on the machine, like /var/www/

Set this directive as a path and use ServerName for the first and ServerAlias for every other name you want to point to your files, defined in DocumentRoot.

share|improve this answer

Your Answer


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

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