Apache directory access from outside of DocumentRoot

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 1.1.1.0/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.

One thought on “Apache directory access from outside of DocumentRoot

  1. Hello! I’ve been following your blog for a while now and finally got the courage to go ahead and give you a shout out from Kingwood Texas! Just wanted to tell you keep up the fantastic work!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s