Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

In httpd.conf


ServerName testsite.com:80
DocumentRoot /usr/share/web
<Directory /usr/share/web>
// usual stuff from documentation

Include httpd-vhost is uncommented

in httpd-vhost.conf

NameVirtualHost *

<VirtualHost *>
  DocumentRoot "/usr/share/web/a"
  ServerName www.testsite.com
  ServerAlias testsite.com

<VirtualHost *>
  DocumentRoot "/usr/share/web/b"
  ServerName site.testsite.com
  ServerAlias site

in /etc/hosts localhost testsite.com www.testsite.com site.testsite.com

if I goto site.testsite.com, testsite.com www.testsite.com I get served the page from /usr/share/web


share|improve this question

migrated from stackoverflow.com Sep 8 '12 at 19:16

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

1 Answer 1

In httpd.conf, you're specifically listening on port 80, but your virtual hosts are not specifying a port.

Change to the following:

NameVirtualHost *:80

and in each of your VirtualHost containers:

<VirtualHost *:80>

Also, you're defining the same ServerName in httpd.conf and httpd-vhost.conf -- I recommend changing the one in httpd.conf to something else.

share|improve this answer

Your Answer


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