Search code examples
amazon-web-servicesx-sendfileapache2.4

How to install xsendfile for httpd 2.4 on amazon linux ami?


How to install xsendfile for httpd 2.4 on amazon linux ami? Default package repositories from amazon and epel do not have a package for httpd 2.4, only for httpd 2.2. I would prefer not to compile the module if possible. Thank you.


Solution

  • I'm not aware of a quick Yum/apt-get style install for X-sendfile for Apache24 on an EC2 instance at the time of writing this answer, however compiling and installing the module your self is super easy:

    Prepwork

    Download mod_xsendfile.c from download section the link below

    https://tn123.org/mod_xsendfile/
    

    Install GCC for compiling

    sudo yum install gcc
    

    We need httpd24-devel for apxs

    sudo yum install httpd24-devel.x86_64
    

    Compiling and installation

    sudo apxs -cia mod_xsendfile.c
    

    Edit your http.conf add

    <IfModule mod_xsendfile.c>
      XSendFile on
      XSendFilePath /home/path/to/private/files/to/serve/
    </IfModule>
    

    Restart Apache24

    sudo service httpd restart
    

    Done !

    Check your phpinfo or apache_modules() to confirm all good and modify settings to your liking. Enjoy efficient downloads :)