Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dedicated linux machine on the internet and I want to be able to access subdomains directly like:

I've setup httpd.conf as follows:

NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot /var/www/html/

<VirtualHost *:80>
  DocumentRoot /home/david/public_html

<VirtualHost *:80>
  DocumentRoot /home/matthew/public_html

But the subdomains are not accessible. What changes, if any do I need to make in /etc/hosts? I tried: localhost.localdomain localhost
# Auto-generated hostname. Please do not remove this comment. vps

and localhost.localdomain localhost
# Auto-generated hostname. Please do not remove this comment. vps david matthew

But neither worked.

Q1: Do I need to change any DNS setting(s)?

Q2: Do I need to set some special permissions on /home or /home/[user]?

share|improve this question

I am assuming that by "But the subdomains are not accessible" you mean they are not accessible remotely. If that is the case, then adding them to /etc/hosts will not help, as /etc/hosts only overrides local hostname lookups. If you want the subdomains to be accessible from the internet, you need to add them to the DNS for your domain name. Your hosting provider should be able to help you with that.

share|improve this answer
Thanks for the @insyte! I think I missed that in my understanding... :( – siliconpi Jan 25 '11 at 5:10
actually, godaddy (where the domain has been registered) says: "DNS Manager: (Not hosted here)" – siliconpi Jan 25 '11 at 5:32
and the hosting provider has provided a VPS within which this site is hosted. – siliconpi Jan 25 '11 at 5:32
So where is the DNS managed? You can find out by looking at the domain servers listed in the WHOIS record or in the output of "dig ns" – Insyte Jan 25 '11 at 6:11
Also it would be helpful if you describe what you mean by "not accessible." What error shows up in a browser when you attempt to access the domains? – Insyte Jan 25 '11 at 6:12

Check with your hosting provider or if you have access to your domain panel create desired subdomain and map the IP address of your machine in A Record for all those virtaulhosts so that the subdomain will point to your server and apache via your virtualhost configuration will through the desired pages.

good luck!!


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.