How to Change Default ‘DocumentRoot’ Directory in Apache Linux

Change DocumentRoot directory in Apache Linux

If you are reading this article now, most probably you are experiencing one of the most common issues that a lot of webmasters and Linux sysadmins are facing; how to change the default DocumentRoot in Apache.

What is Apache

What is DocumentRoot

The default DocumentRoot for Apache is:


This means that if you upload your WordPress files/folders and a new sub-directory named my-wordpress/ then your WordPress website will be accessible as follows:

In this article we will explain how to change the default DocumentRoot in Ubuntu/Debian and CentOS/RHEL/Fedora.

Change DocumentRoot in Apache on Ubuntu / Debian


Changing Apache’s DocumentRoot in Linux CentOS/RHEL/Fedora


Open the config file with your favourite text editor and search for DocumentRoot

# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
DocumentRoot "/var/www/html"

Once you locate the DocumentRoot, change the path to the new target directory and make sure that it is read/writable by Apache web server. Once you have modified the DocumentRoot path, save the file and restart apache web server as follows:

# systemctl restart apache     [for SystemD]
# service httpd restart [for SysVinit]

That’s it! If no errors occur during Apache’s restart, you should be able to access your Website from any browser.


Web Hosting, Servers, Colocation & Data Center Services (