1

I just set up LAMP on a new CentOS server. Previously when I installed LAMP on Ubuntu, I always needed to create a virtual host definition for each website I create in my /var/www directory.

But on CentOS, I realised once I put my website into my /var/www directory, it's immediately visible on my browser.

I included this directive: Include conf/vhosts/*.conf in my httpd.conf file in order to define virtual hosts for specific sites. Inside my vhost directory, I have defined my *.conf files.

Can anyone tell me what needs to be edited, possibly in httpd.conf, to stop sites that don't have an individual /vhosts/*.conf file from displaying when visited?

Below is my default virtual host definition information which I amend for each new site:

<VirtualHost var/www/aSite:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot var/www/aSite
    ServerName myServer
    ErrorLog var/www/aSite/logs/error_log
    CustomLog var/www/aSite/logs/access_log common
</VirtualHost>
2
  • 1
    You know that <VirtualHost var/www/aSite:80> doesn't make any sense, right? The argument before the port number (:80) is supposed to be a hostname or ip address (or *).
    – larsks
    Mar 30, 2012 at 1:10
  • :-) yes! I just put aSite in there as a place holder
    – sisko
    Apr 3, 2012 at 9:12

2 Answers 2

1

I'll tell from my mind and memory (can't verify on CentOS), you have somewhere in httpd.conf

This module creates dynamically configured virtual hosts, by allowing the IP address and/or the Host: header of the HTTP request to be used as part of the pathname to determine what files to serve. This allows for easy use of a huge number of virtual hosts with similar configurations.

  • VirtualDocumentRoot defined into /var/www/(something) + possible VirtualScriptAlias

PS: Can you tell me, why you want to stop this (nice, from my POV) behavior?

0

I recently setup a centos 7 web-server with virtual hosts and I added a <VirtualHost> directive for a blank webpage or coming soon page. This <VirtualHost> directive needs to be above Include conf/vhosts/*.conf in the httpd.conf file.

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.