This tutorial explains how to change default Apache2 webroot directory, from which your Apache2 webserver will load your websites.
Prerequisites: This tutorial assumes that you have already installed Apache2 webserver on your system.
- How to install Apache2 webserver on CentOS 6, 7 tutorial can be found here.
1. First of all, create the new webroot directory for your websites, for example:
sudo mkdir -p /home/public_html/www/
2. Then, open the Apache2 webserver configuration file
/etc/httpd/conf/httpd.conf and find the directive
sudo nano /etc/httpd/conf/httpd.conf
3. Then, change the default webroot location in the
Note: Since you have changed the directive for the default webroot directory, you might wish to change the directories for the complimenting directives as well.
4. Then, save and exit the configuration file and restart your Apache2 webserver for changes to take affect
sudo systemctl restart httpd.service
5. Finally, set the correct ownership
sudo chown -R apache:apache /home/public_html/www/
Your default “
It Works” page should be loading as soon as you try to open your website in your web browser.