How to Find Apache Document Root in Linux

Take Your Linux Skills to the Next Level All courses, certifications, ad-free articles & community — from $8/mo
Join Root →
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
From $8/mo · or $59/yr billed annually · Cancel anytime

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.

Root Plan
Premium Linux Education for Serious Learners

Take Your Linux Skills to the Next Level

Root members get full access to every course, certification prep track, and a growing library of hands-on Linux content — with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Access to Linux certifications (RHCSA, RHCE, LFCS and LFCA)
Access new courses on release
Get access to weekly newsletter
Priority help in comments
Private Telegram community
Connect with the Linux community
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

1 Comment

Leave a Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Root Plan Premium Linux Education for Serious Learners

Before You Go - Upgrade Your Linux Skills

Root members get everything in one place, with new courses added every month.

What You Get
Ad-free access to all premium articles
Access to all courses: Learn Linux, AI for Linux, Bash Scripting, Ubuntu Handbook, Golang and more.
Linux certifications: RHCSA, RHCE, LFCS and LFCA
Access new courses on release
Weekly newsletter, priority support & Telegram community
Join Root Today and Start Learning Linux the Right Way
Structured courses, certification prep, and a community of Linux professionals - all in one membership.
Join Root Plan →
$8/mo · or $59/yr billed annually