How To Find Apache Document Root

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/domain.com

then an access to http://www.domain.com/index.html refers to /home/www/domain.com/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

Leave a Reply

Your email address will not be published. Required fields are marked *