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

vhost.conf , located in etc/httpd/vhost.d/

NameVirtualHost *:80

    <VirtualHost *:80>
         ServerAdmin webmaster@example.com
         ServerName localhost
         ServerAlias localhost.example.com
         DocumentRoot /var/www/html/example.com/public_html/
         ErrorLog /var/www/html/example.com/logs/error.log
         CustomLog /var/www/html/example.com/logs/access.log combined
    </VirtualHost>

    <VirtualHost *:80>
         ServerAdmin webmaster@example.org
         ServerName example.org
         ServerAlias www.example.org
         DocumentRoot /var/www/html/example.org/public_html/
         ErrorLog /var/www/html/example.org/logs/error.log
         CustomLog /var/www/html/example.org/logs/access.log combined
    </VirtualHost>

httpd.conf, settings on default, added onto end:

Include /etc/httpd/vhosts.d/*.conf

Root directories:

DocumentRoot "/var/www/html"

Respective directories for the virtual hosts created in above folder. Permissions all look correct. Index.php file in each public_html directory. However when I punch in localhost now it just takes me to the default apache 2 page, should I remove the line Include /etc/httpd/vhosts.d/*.conf webserver works as required from default directory, serving whichever index file I put there.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Base on from what typed, it doesn't sound like you have syntax errors. So do this in /etc/hosts file (if you are doing directly from the server):

127.0.0.1   example.org
127.0.0.1   example.com

Or on your PC's host file:

YOURSERVERIP  example.org
YOURSERVERIP  example.com

And the browse to that domain instead of localhost.

The reason why you just see the apache web page is because Apache needs to know which goes to go to - since you don't have DNS setup yet, nothing is send to Apache with the hostname in question, so it defaults to the document root.

share|improve this answer

Since the Include line is after your VirtualHosts, I would guess that one of those included vhosts is overriding your new ones. What does "httpd -S" say? (it may not be "httpd", it may be "apache2" or something else). The -S flag will show you all the virtualhosts you have configured and will help with debugging.

You could try removing the include line and see if that makes your new blocks work. You may also check your error log to see if there are any warnings about your config file.

share|improve this answer

Your Answer

 
discard

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.