FREE TRIAL

Deploy a Free VPS Server Worldwide. No Credit Card Required.

Start Free Trial
  • +357 2425 0808
  • Login
  • English

Home

Blog

How to Change Default ‘DocumentRoot’ Dir...

How to Change Default ‘DocumentRoot’ Directory in Apache Linux

How to Change Default ‘DocumentRoot’ Directory in Apache Linux

NetShop ISP

NetShop ISP · Blog Author

Feb 18, 2021 · Tutorials

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

Apache is one of the most popular web servers that is used in various Linux distributions, as well as Windows (i.e. LAMP environment). The apache web server is used to deliver content and serve multiple web queries simultaneously.

What is DocumentRoot

DocumentRoot is the root directory from which the Apache web server serves the content for your website’s visitors.

The default DocumentRoot for Apache is:

/var/www/html

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:

http://www.JohnDoe.com/my-wordpress/

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

Open for editing the following files depending on whether you are on Ubuntu and Debian:

/etc/apache2/sites-enabled/000-default
/etc/apache/apache2.conf

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

In CentOS/RHEL/Fedora Linux distributions the Apache’s configuration file is the following:

/etc/httpd/conf/httpd.conf

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.

Categories

Backup
6
Business Continuity
4
Cloud Hosting
10
Colocation
4
Company Updates
1
Cryptocurrencies
1
Data Centers
12
Dedicated Servers
4
Disaster Recovery
3
Forex
25
Gaming
1
iGaming
33
Industry News
32
Interviews
10
Joomla
9
Magento
5
Managed Services
1
Operating Systems
1
Press Releases
65
Product News
6
Resellers
1
Security
25
Software & Apps
1
Streaming
1
Tech Startups
12
Tutorials
61
Uncategorized
389
Vps Hosting
11
Web Design & Development
3
Web Hosting
44
Webinars
1
Wordpress
14

Free VPS Trial

No Credit Card Required.

Recent Posts

How To Enable Remote Connections to SQL Server

How To Enable Remote Connections to SQL Server

27 March, 2023

How To Fix Error Failed to download metadata for repo in CentOS 8

How To Fix Error Failed to download metadata for repo in CentOS 8

23 March, 2023

How can Forex Brokers be Protected from DDoS Attacks

How can Forex Brokers be Protected from DDoS Attacks

20 March, 2023

NetShop ISP Bronze Sponsors for the University of Cyprus at Harvard WorldMUN 2023

NetShop ISP Bronze Sponsors for the University of Cyprus at Harvard WorldMUN 2023

15 March, 2023

Top 5 Cloud Computing Trends in 2023

Top 5 Cloud Computing Trends in 2023

13 March, 2023

#letushostyou

Award Winning Hosting Provider established in 2004.

Best iGaming Service ProviderISO Certified

120 Faneromenis Avenue, Imperial Tower, 2nd Floor, Larnaca 6031, Cyprus

Products

Bare Metal Servers

Customized Servers

Virtual / Cloud Servers

Forex VPS

Storage VPS

cPanel Web Hosting

Reseller Web Hosting

Colocation

Addons

Premium DNS

Email Hosting

Cloud Backup

DDoS Protection

Licenses

SSL Certificates

Domain Names

Premium SLAs

About Us

Data Center Locations

Looking Glass

Our Company

Contact Us

Careers in Cyprus

Become a Partner

Awards

Certifications

© 2023 S.S. NetShop Internet Services Ltd. All rights reserved.  Terms & Conditions  |  Privacy Policy
CY Reg. Number: HE 217340 | EU VAT Number: CY10217340J

Visa
Mastercard
PayPal
Bitcoin
Tether
Ethereum
Litecoin
Wise
Revolut
Wire Transfer