Friday, July 31, 2015

Change Apache Server Root in Linux

There are a million blogs that tell you how to install a LAMP stack on any linux distro.

But what if you want to move your server's root folder?

The directories I'm going to mention are specific to Fedora, but the files remain the same.

Follow these steps carefully:

1. Create your new root folder.
    For instance, "/home/sahay/newRoot"

2. Edit the Apache servers Config file:
    In Fedora, you'll find this file in the path "/etc/httpd/conf/httpd.conf"
    So, the default value of the servers root directory is "/var/www"
    We need it to be in "/home/sahay/newRoot"
    DO NOT replace every occurrence of "/var/www" with "/home/sahay/newRoot".
    Let them be as they are.
   For the sole purpose of changing your root directory, we have something called "Virtual Host."
    Type the following at the end of the file:

        <VirtualHost *:80>
            DocumentRoot /home/sahay/newRoot
            <Directory "/home/sahay/newRoot">
               
Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted

           
</Directory>
       </VirtualHost>
If you want your PHP script to create a file in your server folder, whether default or a new server folder you've created, you need to make some changes. Follow this LINK.

No comments:

Post a Comment