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

I've been given a new domain and I want to point it to a specific directory on my server: var/www/specific/path

What are the steps for doing it ? Could you suggest me a tutorial ?

I need to repeat the same operations for several domains.



NameVirtualHost a.b.c.d //I've hidden my real ip

    DocumentRoot /var/www/sites/website
    CustomLog /var/log/apache2/ combined
share|improve this question

1 Answer 1

up vote 4 down vote accepted

I'm assuming you want to host multiple sites on a single IP address and that you're using apache. If so, then essentially, the following lines of code in my httpd.conf do the job for me:

NameVirtualHost a.b.c.d:80

    DocumentRoot /path/to/site1/documentroot
    CustomLog /usr/local/apache/logs/ combined

    DocumentRoot /path/to/site2/documentroot
    CustomLog /usr/local/apache/logs/ combined

Where a.b.c.d is your server's IP address. Repeat VirtualHost declarations as you need them. The CustomLog declaration isn't vital, but it helps me to keep my sites' logs separately from one another.

You can find more documentation on apache at; click on the version of your apache server, then enter (eg) NameVirtualHost in the search box (though the doco for that can also be found directly at - it's not a feature that changes much between versions).

share|improve this answer
Sorry, I should have added that the apache project has a very nice piece of doco on all of this at –  MadHatter Sep 30 '10 at 10:09
@MadHatter Sorry for the delay, they finally transfer the domain, so I can only test now. Shortly, I cannot make it work, the domain doesn't lead to my website. I've updated the question with my current configuration. What am I missing ? –  Patrick Oct 7 '10 at 14:59
Also, this is what I get when I do add the NameVirtualHost line: [Thu Oct 07 16:51:46 2010] [warn] NameVirtualHost a.b.c.d:80 has no VirtualHosts –  Patrick Oct 7 '10 at 15:01
Could you confirm that, both on the machine in question, and on another random machine, when you nslookup, you get a.b.c.d ? –  MadHatter Oct 7 '10 at 15:39
@MadHatter I actually get another ip. Wow. But I don't get why, I bought a VPS slice and they assigned me a specific ip. Then I transferred the domain, and they just assigned it to another ip ?! –  Patrick Oct 8 '10 at 7:11

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.