Vagrant + Apache Defaults = Corrupted Files

Written in

by

Problem: You just started using vagrant as a development environment and now your getting errors in your javascript files like 'Illegal Character' appended to the file you just edited.
Restoring the edited file from git fixes the error.

Solution: Your problably being hosed by the 'EnableSendfile' directive.
Disable it by adding "EnableSendfile Off" to your apache config file.

Sendfile allows apache to send data from a file without doing a seperate read and send operation. It however doesn't work well with NFS shares.
While I'm not sure how the shared folder in vagrant works, it appears to be impacted by this setting. Here are the apache 2.2 docs for this module.

Thanks to the folks of the virtualbox forums for discussing this issue and possible solutions and preventing me from wasting another day on this issue.

Tags

2 responses to “Vagrant + Apache Defaults = Corrupted Files”

  1. Ben Bolton Avatar
    Ben Bolton

    Thanks for blogging about this… saved us a ton of time.

  2. Patrick Avatar
    Patrick

    And thank YOU very much for sharing! This had been an issue that plagued me for a little while. While I searched for it a long time ago and found nothing, I decided to try again. This time your article came up with just the right combination of keywords so that has helped reduce a ton of frustration on my end. Thanks again.

Verified by MonsterInsights