Table of Contents
This tip is about the how to Find Apache Document Root in Linux. So read this free guide, How to Find Apache Document Root in Linux step by step. If you have query related to same article you may contact us.
How to Find Apache Document Root in Linux – Guide
For many decades I have been hosting my own websites. I’ve been using Apache as my server software since migrating from OS/2 to Linux over 20 years ago. For a basic installation, Apache is reliable, popular, and simple to configure. Setting up for a more complicated arrangement, like many sites, isn’t much more difficult. The Apache web server must be installed and configured with root privileges. The firewall configuration must also be done as root. Viewing the results of this operation in a browser must be done as a non-root user. (On my virtual host, I use user student.) One of the most used web servers on the internet is Apache.
More than half of all active websites are served by it. Despite the fact that there are a plethora of web servers that can deliver your content, knowing how Apache works is beneficial due to its widespread use. This article will look at several common configuration files and the settings that can be configured in them. This tutorial will follow the Apache file architecture used by Ubuntu/Debian, which differs from how other distributions build the configuration hierarchy.
How to Find Apache Document Root on Linux
The DocumentRoot is the top-level directory in the document tree visible from the web, and this directive defines the directory in the configuration from which Apache2 or HTTPD looks for and serves web files from the requested URL to the document root.
DocumentRoot “/var/www/html”
so accessing http://domain.com/index.html refers to /var/www/html/index.html. The DocumentRoot must be described without a slash final. In this quick short we will show you how to find the Apache DocumentRoot directory on a Linux system.
Finding the Apache Document Root
To get the Apache DocumentRoot directory on Debian, Ubuntu Linux and their 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 on 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 on CentOSS If you want to change the location of the Apache DocumentRoot directory, read our article which explains How to Change Apache’s default ‘DocumentRoot’ directory on Linux. On a side note, the individual directories for all your virtual hosts should be located in 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 your directories as shown.
$ sudo mkdir -p /var/www/html/example1.com/ $ sudo mkdir -p /var/www/html/example2.com/
Final note
I hope you like the guide How to Find Apache Document Root in Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.