Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

virtual hosts DocumentRoot not being changed

Tags:

apache

dns

Don't think my virtualhost is working correctly. This is what I have inside of httpd.conf...it is the last thing in the file:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/testing
ServerName testing.aa.local
</VirtualHost>

In my /etc/hosts file:

127.0.0.1 testing.aa.local

Now when I go to testing.aa.local it shows the index page of the root of the site. In httpd.conf the document root is DocumentRoot /var/www/html. It appears it is taking that document root and not the VirtualHost documentroot. When I restart httpd there are no errors. When I say httpd -S it says:

$ sudo /usr/sbin/httpd -S 
VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers:
_default_:443          aa.local (/etc/httpd/conf.d/ssl.conf:81)
*:*                    aa.local (/etc/httpd/conf/httpd.conf:974)
*:80                   is a NameVirtualHost
         default server testing.aa.local (/etc/httpd/conf/httpd.conf:1031)
         port 80 namevhost testing.aa.local (/etc/httpd/conf/httpd.conf:1031) Syntax OK

Anyone understand why when I go to testing.aa.local it is showing me the index page of /var/www/html rather than /var/www/html/testing? Again, /var/www/html is defined as the httpd.conf file as the DocumentRoot but later on I declare the virtualhost container and so I thought it should overwrite it?

like image 429
user983223 Avatar asked Feb 26 '12 02:02

user983223


People also ask

What is DocumentRoot in Apache server?

The DocumentRoot is the top-level directory in the document tree visible from the web and this directive sets the directory in the configuration from which Apache2 or HTTPD looks for and serves web files from the requested URL to the document root. For example: DocumentRoot "/var/www/html"

Where is DocumentRoot in apache2?

On a fresh installation of Apache, the document root is located at /var/www/html . By following the prerequisite guides, however, you created a new document root, /var/www/ example.com /html .


1 Answers

In my httpd.conf file there are a virtualhost container all ready. I commented it out and it now works.

like image 98
user983223 Avatar answered Sep 30 '22 18:09

user983223