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

by on December 1, 2007 · 10 comments· Last updated December 1, 2007

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).

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



You should follow me on twitter here or grab rss feed to keep track of new changes.

Featured Articles:

{ 10 comments… read them below or add one }

1 douglas April 30, 2008 at 1:00 am

Thank you VEEERRRRRYYYYYYYYY MUCCCHHHH!!!!!!!

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

Reply

2 Rajesh.G November 1, 2010 at 10:30 am

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

Reply

3 Steve Pham May 5, 2008 at 1:24 pm

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

Reply

4 Al March 25, 2009 at 11:26 am

Thank you so much!!!

Reply

5 luke March 31, 2009 at 12:39 pm

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

Reply

6 Felix December 22, 2009 at 12:51 pm

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

Reply

7 Rajesh.G November 1, 2010 at 10:39 am

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

Reply

8 Anita January 13, 2012 at 8:17 pm

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

Reply

9 Marcelo Zoel September 13, 2012 at 5:48 pm

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

Reply

10 Space Gypsy March 12, 2013 at 8:53 pm

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.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 3 + 10 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Tagged as: , , , , , , , , , , , , ,

Previous post:

Next post: