How To Find Apache Document Root

by on May 13, 2008 · 2 comments· LAST UPDATED October 20, 2008

in , ,

Q. How do I find out my Apache webserver document root under Linux / UNIX / BSD operating systems?

A. Apache has DocumentRoot directive.

This directive sets the directory from which Apache will serve files. Unless matched by a directive like Alias, the server appends the path from the requested URL to the document root to make the path to the document. Example:

DocumentRoot /home/www/theos.in

then an access to http://www.theos.in/index.html refers to /home/www/theos.in/index.html.

Finding Apache Document Root

Use grep command as follows:
# grep -i 'DocumentRoot' httpd.conf
RHEL / Red hat / Fedora / CentOS Linux specific command:
# grep -i 'DocumentRoot' /etc/httpd/conf/httpd.conf
FreeBSD specific command:
# grep -i 'DocumentRoot' /usr/local/etc/apache22/httpd.conf
Sample output:

# DocumentRoot: The directory out of which you will serve your
DocumentRoot "/usr/local/www/apache22/data"

/usr/local/www/apache22/data is default document root for your website.

To modify DocumentRoot use vi command and change DocumentRoot:
# vi /etc/httpd/conf/httpd.conf

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 2 comments… read them below or add one }

1 Neang chanraksmey June 17, 2011 at 2:02 am

i want to ask you about Linux question
– what does documentRoot mean in webserver configuration?
– what are the run levels? Explain them briefly?

Reply

2 Unsa Tisfied February 11, 2014 at 5:42 am

And what if there is no document root specified in the httpd.conf file??? What is the default document root? Is there a way to query apache from the terminal for this value?

Reply

Leave a Comment

Tagged as: , , , , , , , ,

Previous Faq:

Next Faq: