How to Find Apache Document Root in Linux

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"

then access to http://domain.com/index.html refers to /var/www/html/index.html. The DocumentRoot should be described without a trailing slash.

In this short quick tip, we will show you how to find the Apache DocumentRoot directory in a Linux system.

Finding Apache Document Root

To get the Apache DocumentRoot directory on Debian, Ubuntu Linux and it’s derivatives such as Linux Mint, run the following grep command.

$ grep -i 'DocumentRoot' /etc/apache2/sites-available/000-default.conf
$ grep -i 'DocumentRoot' /etc/apache2/sites-available/default-ssl.conf
Find Apache DocumentRoot in Ubuntu
Find Apache DocumentRoot in Ubuntu

On CentOS, RHEL and Fedora Linux distributions, run the following command.

$ grep -i 'DocumentRoot' /etc/httpd/conf/httpd.conf
$ grep -i 'DocumentRoot' /etc/httpd/conf.d/ssl.conf
Find Apache DocumentRoot in CentOS
Find Apache DocumentRoot in CentOS

Note that the location of the DocumentRoot directory may vary depending on the value of the DocumentRoot directive set in the Apache or httpd configuration.

If you want to change the location of the Apache DocumentRoot directory, please read our article that explains How to Change Default Apache ‘DocumentRoot’ Directory in Linux.

On a side note, the individual directories for all your virtual hosts must be located under the DocumentRoot. For example, if your DocumentRoot is /var/www/html, and you have two sites called example1.com and example2.com, you can create their directories as shown.

$ sudo mkdir -p /var/www/html/example1.com/
$ sudo mkdir -p /var/www/html/example2.com/

Then in the virtual host configuration files, point their DocumentRoot to the above directories.

Here are some additional guides about Apache web server, that you will find useful:

  1. Useful Commands to Manage Apache Web Server in Linux
  2. 3 Ways to Check Apache Server Status and Uptime in Linux
  3. How to Enable Apache Userdir Module on RHEL/CentOS
  4. Apache Virtual Hosting: IP Based and Name-Based Virtual Hosts
  5. How to List All Virtual Hosts in Apache Web Server

That’s It! If you know any other useful way to find the Apache DocumentRoot directory, do share with us in the comment section below.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

1 thought on “How to Find Apache Document Root in Linux”

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.