≡ Menu

How to find the document root folder on Apache on Linux?

The question – I recently installed Apache on my Linux box. I need to find the directory in which I should put my HTML files. How do I find the default document root that Apache httpd users? I am using CentOS.

There is a directive called DocumentRoot in the httpd.conf file.

First locate your http.conf file:

httpd -V

Then, run the following command:

grep -i DocumentRoot /etc/httpd/conf/httpd.conf

This will output something like the following:

# DocumentRoot: The directory out of which you will serve your
DocumentRoot "/var/www/html"
# This should be changed to whatever you set DocumentRoot to.
# DocumentRoot /www/docs/dummy-host.example.com
[root@server ~]#

So your default DocumentRoot is:


You must put your html and php files in this directory.

Using virtual hosts

If you are using virtual hosts, the document root will be different for each virtual host.

Generally, on CentOS, your virtual host configuration file will be:


It is also possible that you have put all of your virtual hosts in httpd.conf. So find where your virtual hosts are located.

An example virtual host is as follows:

NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin info@ewhathow.com
ServerName ewhathow.com
ServerAlias www.ewhathow.com
DocumentRoot /srv/www/ewhathow.com/public_html/
ErrorLog /srv/www/ewhathow.com/logs/error.log
CustomLog /srv/www/ewhathow.com/logs/access.log combined

Note here that the document root for the virtual host ewhathow.com is different from the default document root! Find your virtual hosts file and check each virtual host for a separate document root.

{ 0 comments… add one }

Leave a Comment