Apache 2.2 has a document root that by default is /var/www/html. If you want to share directory not in document root, one way to do it is using the <Directory> directive. For instance I wanted to share a CentOS 6.4 install DVD which I had mounted using loop back. The way to mount an ISO file via loopback is:
mount -o loop /vm1/iso/CentOS-6.4-x86_64-minimal.iso \ /mnt/CentOS6.4/
To share the above mentioned directory via apache, in /etc/httpd/conf.d/ create a file with a .conf extension, the filename can be anything you want, in this case, let’s say the file is called local.conf. In the file place the following:
Alias /centos64 /mnt/CentOS6.4 <Directory /mnt/CentOS6.4> Order deny,allow Deny from all Allow from .example.com Allow from localhost Allow from 22.214.171.124/255.255.255.0 Options +Indexes </Directory>
The ‘Alias’ part lets you access the URL with http://example.com/centos64 instead of having to type in the full directory path.
The Deny/Allow control who can access the file and the +Indexes allows directory browsing.
Now you are ready to use the URL for network installs for CentOS or whatever else you need it for!
How do you share directories via Apache? Leave your comments below.