logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: How do I setup apache to download files?
Author
logantennis



Joined: 19 Dec 2013
Posts: 1
Location: australia, brisbane

PostPosted: Thu 19 Dec '13 9:37    Post subject: How do I setup apache to download files? Reply with quote

ie.

http://www.myplace.com.au/MYFILE.EXE Confused

really don't know how to setup apache so files are downloadable from it. I guess I should also be using SSL.
Back to top
Anaksunaman



Joined: 19 Dec 2013
Posts: 54

PostPosted: Sat 21 Dec '13 12:25    Post subject: How do I setup apache to download files? Reply with quote

Directly accessing files in the URL, as in your example, should work automatically. No additional configuration should be necessary. If you wish to serve the file via SSL, make sure Apache is capable and set-up to run an SSL website, and then serve the file from a link to that site (e.g https://secure.tld/myfile.exe).

Make sure you are accessing the correct URL to access a file.

Remember that all files in Apache are essentially served from a directory tree very much like your normal files. So if your website is "mysite.tld", and you place a folder in your main web root directory called "files" and finally place a file called "my.exe" there in the "files" directory, the url to download the file would be:

mysite.tld/files/my.exe

In your example case, the file would be located in the web root directory, not inside any additional folder (remember that the web root directory is a folder in and of itself). Remember, though, that if your web URL is something like myid.hostsite.tld, often "myid" is the root directory where the html files are served from and is often itself (again) a folder.

Make certain your server installation allows access to the directory you are requesting.
If your server runs a particularly permission-heavy environment, Apache may not simply be able to access the files (not have "permission"). Likewise, requesting files outside the Apache web root directory (i.e. where all your html files are stored) will almost certainly guarantee you won't be able to access these files unless you make certain these directories are available to Apache.

The solution, generally, is to grant Apache access to that directory (folder).

The club-it-to-death method is to simply make Apache part of a group that can access the folder. Then you place an alias in the appropriate .conf file that defines the site itself (httpd.conf, http-ssl.conf, vhosts.conf, etc.) like this:

Code:
#Windows style -- Unix style omits the surrounding quotes. If you are on Windows, use the quotes.
Alias /url_name "C:/Path/to/folder"

Make certain mod_alias is enable in httpd.conf in case you try to do this. You can read more about mod_alias here:
http://httpd.apache.org/docs/2.2/mod/mod_alias.html

A more elegant solution, however, is to use a symbolic link (http://en.wikipedia.org/wiki/Symbolic_link). Basically, you create a second folder in your web root directory (you can call it what ever you like) then "link" it with an existing directory so Apache can have access to that directory without changing permissions. Think of it like a web-enabled version of a desktop shortcut. These kinds of links are usually relegated to command line tomfoolery, so for Windows 7/8 I would recommend:

Link Shell Extension 3.7.5
http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html

Downloads are towards the bottom of the (very) long page. Make sure to get the correct version for your copy of Windows.

The only caveat to using symbolic links is that you may have to twiddle with allowing Apache to follow symlinks in the .conf file that defines your site, but this usually isn't hard to do, it it is even necessary at all.

If your are encountering an issue, there are a couple reasons why this could be:

* Your browser is interfering with your download.
This most typically happens when your browser is set to automatically open, play or block particular files. This is not an Apache configuration issue, generally.

* PHP or your CMS framework could be messing things up.
If you run a web server or site that relies on PHP (e.g. it is installed, its running) and you have installed a CMS like Wordpress, which runs PHP to operate, you may have to adjust your PHP settings to allow the file to be downloaded. As an extreme example, some hosting companies limit the amount of memory PHP can use for certain activities and if a file's size exceeds this amount, it can cause issues.

Hope this helps!
Back to top


Reply to topic   Topic: How do I setup apache to download files? View previous topic :: View next topic
Post new topic   Forum Index -> Apache