JS and CSS files in vagrant not properly encoded when saved outside of the VM

后端 未结 2 1372
小蘑菇
小蘑菇 2020-12-04 10:49

I\'m running vagrant on OSX, Ubuntu, and Windows 7 and using vim and Netbeans as IDEs on the host machine. The VM is running CentOS 6.3 and Apache 2.2. The docroot is set to

相关标签:
2条回答
  • 2020-12-04 11:29

    I had this problem this morning. Set EnableSendfile to off in your httpd.conf.

    If you look at your httpd.conf it says "turn this off if you serve from NFS-mounted filesystems." In http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile it explains that "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."

    Since your windows host has an ntfs file system, the linux guest doesn't properly cache the file with sendfile and so apache needs to send the file itself. This may cause a marginal slowdown when requesting files from apache, but it should be negligible.

    0 讨论(0)
  • 2020-12-04 11:31

    It depends on what server you are using.

    For Nginx: in /etc/nginx/nginx.conf:

    change the line that contains sendfile on; to sendfile off;.

    For Apache: in /etc/httpd/conf/httpd.conf:

    change remove comment for EnableSendfile off;

    And don't forget restart your Nginx or Apache. If it still doesn't work, exit and vagrant reload or something like that - restart your VM.

    0 讨论(0)
提交回复
热议问题