- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the root directory of an Apache server on Linux?
Apache web server is one of the most used web servers across all the platforms even after including different Linux distributions and windows. Apache server is an open source HTTP server that is mainly used to deliver web content and can also be used to serve many queries at once.
In this article, I will try to explain how to change the root directory for Apache web server.
It is usually the case that to change the root directory we must first be aware of its exact location and in the case of the Apache server, the root directory which is also known as DocumentRoot is present inside the folder −
The DocumentRoot is the directory from which the Apache server will read the contents that the visitor will access over the internet.
Sometimes it is the case that the default DocumentRoot can also be present inside the directory.
Now the next step is to locate the file in which this DocumentRoot is configured. Just type the following command in the terminal −
Now next step is to open this .conf file in your favorite text editor, I am making use of nano, and so the command for me looks something like this −
sudo nano /etc/apache2/sites-available/000-default.conf
and now we need to find the text “DocumentRoot” in the above file and change the location that might look something like this −
To whatever destination you want.
We also need to make a similar change in the apache2.conf file, for that just type the following command to the terminal
sudo nano /etc/apache2/apache2.conf
And then, try to find the following content in the above file
<Directory /var/www/html/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
Now just change the /var/www/html to the directory that you changed to in the default.conf file and save your file and restart the server with the command shown below −
sudo service apache2 start
- How to Setup Virtual Hosts with Apache Web Server on Linux
- How to Change the Default Home Directory of a User on Linux?
- How to Change Apache Default Web Root Folder to a New Location on Ubuntu 16.04
- How to execute Python CGI Script on Apache Server?
- How to change the shell working directory in Linux?
- How to change the root directory of the current process in Python?
- How to Configure Nagios Server for Monitoring Apache Server
- How to change file or directory permission in Linux/Unix?
- How to Install and Configure an NTP Client and Server on Linux?
- Copy a directory to an existing directory Linux?
- Running a static site on Apache Server from Docker
- How to Install and Configure NFS Server on Linux
- How to Install and Configure Squid Proxy Server on Linux
- How to find the most recent file in a directory on Linux?
- Websockets Apache Server compatibility in HTML5