CentOS 5 Apache 2.2.3 files failing to download or corrupted download file issue

Recently, I noticed something strange about Apache 2.2.3 version running on CentOS Linux 5 64 bit version. We have centralized NFS server and all 3 web server load balanced using hardware front end (another box running LVS).

ADVERTISEMENTS

All Apache server picks up file via NFS i.e DocumentRoot is set over NFS. The small file such as 2 MB or 5 MB get downloaded correctly but large size files failed to download. Another problem was some clients reported that the file get download but cannot open due to file corruption issue.

After investigation and a little bit googling I came across the solution. You need to disable following two options:

  • EnableMMAP – This directive controls whether the httpd may use memory-mapping if it needs to read the contents of a file during delivery. By default, when the handling of a request requires access to the data within a file — for example, when delivering a server-parsed file using mod_include — Apache memory-maps the file if the OS supports it.
  • EnableSendfile – This directive controls whether httpd may use the sendfile support from the kernel to transmit file contents to the client. By default, when the handling of a request requires no access to the data within a file — for example, when delivering a static file — Apache uses sendfile to deliver the file contents without ever reading the file if the OS supports it.

However, these two directives are known to have problem with a network-mounted DocumentRoot (e.g., NFS or SMB), the kernel may be unable to serve the network file through its own cache. So just open httpd.conf on all boxes and changes the following:
EnableMMAP off
EnableSendfile off

Just restart the web server and voila!
# service httpd restart

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source & DevOps topics via:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
14 comments… add one
  • douglas Apr 30, 2008 @ 1:00

    Thank you VEEERRRRRYYYYYYYYY MUCCCHHHH!!!!!!!

    ALOTTT PLUS PLUS ++++ PLUS!!!!

    • Rajesh.G Nov 1, 2010 @ 10:30

      hi,
      i cant gmail it shows that have problem Apache/2.2.3 (CentOS) Server so kindly help to get rid of this problem

  • Steve Pham May 5, 2008 @ 13:24

    Thanks alot buddy. Been looking through the net for ages, and found this. It really works

  • Al Mar 25, 2009 @ 11:26

    Thank you so much!!!

  • luke Mar 31, 2009 @ 12:39

    Hello,

    I have this same issue on a VPS and i am still trying to resolve the issue.

    Ive disabled both of the settings and are still no further on with this issue.

    Supect i will down grad apache.

    cheers

  • Felix Dec 22, 2009 @ 12:51

    Had issues with a cifs mounted drive. Your advice fixed it! Thanks.

    • Rajesh.G Nov 1, 2010 @ 10:39

      can u tell way how u cleared the prblem i caant do pl pl pl

  • Anita Jan 13, 2012 @ 20:17

    awesome !! Exactly my problem, and exactly the solution !!

  • Marcelo Zoel Sep 13, 2012 @ 17:48

    Thank you a lot, I had this issue with CIFS + apache 2.2.8 and this tutorial solved my problem.

  • Space Gypsy Mar 12, 2013 @ 20:53

    Thanks so much for the solution to this! I spend about 6 hours looking for this solution and had to sift through so much garbage to find this solution.
    This solved my problem and I was running Apache 2.4.4.

  • x Oct 8, 2013 @ 20:48

    Also ran into this problem/solution on a bone stock install of CentOS as a VM:

    httpd-2.2.15-29.el6.centos.x86_64
    Linux my.virtual.server 2.6.32-279.1.1.el6.x86_64 #1 SMP Tue Jul 10 13:47:21 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

    …running under ESXi v4.1.0

  • x Oct 8, 2013 @ 20:52

    Ugh, can’t edit my comment, forgot to mention that there were no network or vmware file-system mappings at all, strictly the local virtual disk file. Possibly triggered by the vmware tools…?

    This is the VM toolset installed at the time:
    vmware-open-vm-tools-8.3.19-1185545.el6.x86_64
    vmware-open-vm-tools-common-8.3.19-1185545.el6.x86_64
    vmware-open-vm-tools-kmod-8.3.19-1185545.el6.x86_64
    vmware-open-vm-tools-nox-8.3.19-1185545.el6.x86_64
    vmware-open-vm-tools-xorg-drv-display-11.0.1.0-0.1185545.el6.x86_64
    vmware-open-vm-tools-xorg-drv-mouse-12.6.7.0-0.1185545.el6.x86_64
    vmware-open-vm-tools-xorg-utilities-8.3.19-1185545.el6.x86_64
    vmware-tools-8.3.19-1185545.el6.x86_64
    vmware-tools-common-8.3.19-1185545.el6.x86_64
    vmware-tools-nox-8.3.19-1185545.el6.x86_64

  • Eric Chen May 20, 2016 @ 21:27

    Usefull!!! thank you so much!!

  • David McGlynn Jun 13, 2016 @ 18:25

    Ubuntu 12.04 – motherboard died, swapped 2 soft-mirrored drives into new PC, and began having this same issue.

    New PC required kernel recompile due to different Realtek Network card on motherboard. This fix solved my issue!

    Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.