What Is the Default DocumentRoot for Apache HTTP Web Server?


Scott Campbell

In this tutorial, we will discuss the default DocumentRoot for Apache HTTP Web Server.

What is DocumentRoot?

The DocumentRoot is the directory in which the web server looks for files to serve on a website. When a user requests a webpage, the web server retrieves the file from the DocumentRoot and sends it back to the user’s browser.

Default DocumentRoot

By default, the DocumentRoot directory for Apache HTTP Web Server is set to /var/www/html. This means that when you install Apache and start it up, any files placed in this directory will be served as webpages.

Changing the Default DocumentRoot

If you want to change the default DocumentRoot directory, you can do so by modifying the Apache configuration file. The configuration file for Apache is usually located at /etc/apache2/apache2.conf.

To change the default DocumentRoot:

  1. Open the Apache configuration file using a text editor.
  2. Search for the line that begins with “DocumentRoot“.
  3. Edit the path after “DocumentRoot” to your desired directory.
  4. Save and close the file.
  5. Restart Apache for changes to take effect.

Benefits of Changing DocumentRoot

Changing the default DocumentRoot can provide several benefits:

  • Organizational Structure: You can structure your website files in a way that makes sense to you and your team by choosing a different directory as your DocumentRoot.
  • Multiple Websites: If you are hosting multiple websites on the same server, changing DocumentRoot allows you to keep the files for each website separate.
  • Security: By placing your web files outside of the default DocumentRoot, you can add an extra layer of security to your server by limiting access to sensitive files.


The default DocumentRoot for Apache HTTP Web Server is /var/www/html. However, you have the flexibility to change it to a directory of your choice. Changing the DocumentRoot can provide organizational benefits, help manage multiple websites, and enhance security.

Now that you know what the default DocumentRoot is and how to change it, you can customize your web server setup according to your requirements.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy