How to Add an External Folder to Apache Root Directory

apache logoHere’s how to add an external folder eg. (a folder that is not part of your web root /var/www). Let’s say you want to publish a data folder that is inside of your home directory. For this you would create an alias in your “default” file under “VirtualHost” section.
1- using your preferred editor open /etc/apache2/site-available/default
2- Under “VirtualHost” section add

Alias /data "/home/user/data"
<Directory "/home/user/data">
	Order allow,deny
	Allow from all
</Directory>

3- Restart apache:

sudo /etc/init.d/apache2 restart

4- place a test html page in your data folder and access through browser

http://hostname/data/test.html
Share This!

Leave a Reply

Your email address will not be published.