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 *: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

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.


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):   example.org   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.

| 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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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