We help IT Professionals succeed at work.

Apache 2 serving files on external drive

AbdellahT asked
Last Modified: 2012-05-08
Hi guys,

I need Apache to serve a huge number of pdf files that live on a NETWORK STORAGE (exteranl drvie)
I want to be able to view each file using http://host/files/file.pdf 
I am using windows 2003.
from what I understand I need to create a virtual host that its root directory is the exteranal media . is this correct?
Please advise the best way to accomplish this?


Watch Question

Go to c:\<where apache is installed>\sites-enabled\

Create a new text file with a virtual host entry like the one below:

<VirtualHost *:80>
ServerName remotefiles.host.domain.com
DocumentRoot <path to files>

I'm assuming you are already serving some content on this server.  If that is the case you will have to create a DNS alias such as remotefiles.host.domain.com so that apache will know which virtual server to access by the URL in the query (the servername variable above).

Once you've done this you will have to restart apache to make the changes visible.


I just made a fresh apache 2 install. I am not serving any pages yet. this is my first task to do.  
You mean create the text file under htdocs? if so how to include it in httpd.conf?
Thanks a lot.

htdocs is probably your default document root.  The sites-enabled folder is inside of your apache installation, probably program files or something.  Files in sites-enabled will be included in the apache configuration when it loads.

If you don't ever plan to serve more than one site from this server then you can just change your default document root by following steps 5 & 6 here: http://www.ricocheting.com/server/apache.html and that should take care of everything for you.  

Be aware that regardless of how you configure this you may run into issues with files that contain non-valid URL characters such as & and ,.


That's probably what I am going to do, I will just change the DocumentRoot to point the extranal drive directory. Thanks a lot.
Question: how to restrict directory browsing ?
This one is on us!
(Get your first solution completely free - no credit card required)
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.