This post will walk you through installing the Apache XSendFile Module to serve files directly from the webserver to the user, without passing the file throught your web application first. To make use of XSendFile in Django you might want to read this great blogpost by Arthur Street. I combined all the answers by timg, Arty (Arthur Street) and pjrobertson at question #12205, to create the steps below. This way I got the XSendFile module working in Django on Apache 2.4.17. Webfaction suggested I should create a new question to make sure this answer would be the top most. Make sure to replace all version specific directory names in the paths, for example change the directory Get current Apache version
Take note of the Apache version being used. Get Apache sourceTry to find Apache sources with a version close to the one being used for your Webfaction webapp, in my case 2.4.17. Download recent stable versions from a mirror site or older versions from the archive.
Extract source
Get APR (Apache Portable Runtime)Download
Extract source
Create directory in the Apache source library
Copy source to source library
Get APR-utilDownload
Extract source
Create directory in Apache source library
Copy source to source library
Build Apache from sourceCreate temporary directory as build target
Change directory to source
Configure
Make
Make install
Module XSendFileChange directory to home
Download Use -4 to force IPv4.
Extract source
Change directory to module XSendFile
Compile
Create shared object
Add XSendFile to Apache modules
Load and enable module XSendFile in Apache configEdit Load the module in the
Enable the module in the
Whitelist the path where the files, you want to send, are located. By adding this in the
Restart Apache
asked 09 Dec '16, 15:36 lspee |
Do you know of a way i can test if this is working? Trying to set it up with django but getting no results and not sure where the problem lies. Thanks for the post regardless, really helpful! Thanks, Joe answered 17 Feb '17, 12:06 joeskru Hey Joe, Thanks for mentioning the typo, I have just corrected it. Concerning your question getting XSendFile to work, you could try the following. Make sure you set the XSendFilePath in your Django projects httpd.conf like the following example. As a test you may want to create a static webapp where you put the files you want to serve, in the example this webapp is called 'my_static_files'. (The 'joe' part should of course be replaced by your real WebFaction account name.)
Place a file in the directory mentioned above, say 'test.pdf'. Add a view to your Django project which is along the lines of:
Hope this helps. Regards, Loe Spee
(17 Feb '17, 14:00)
lspee
You're a gent!, many thanks i have it working. Never messed with Apache before so i was finding it hard to work out if the XSendFile module had installed correctly. Once i had it working i then commented out the new lines in the http.conf and this broke it (showing it's installed correct) Many thanks, Joe
(17 Feb '17, 16:18)
joeskru
|