在颠沛流离的JS和CSS文件无法正常连接codeD时,保存在虚拟机以外 [英] JS and CSS files in vagrant not properly encoded when saved outside of the VM

查看:116
本文介绍了在颠沛流离的JS和CSS文件无法正常连接codeD时,保存在虚拟机以外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在OSX,Ubuntu和Windows 7的运行流浪汉,使用vim和Netbeans作为主机上的IDE。 VM运行的CentOS 6.3和Apache 2.2。该文档根目录设置为 /游民

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 /vagrant.

当我编辑JS或CSS文件并保存,浏览器,然后转身检测非法字符。当我认为在浏览器中的文件I看到其通常指向一个编码问题金刚石问号字符。我可以在VM内Vim打开文件并用保存:宽++ ENC = UTF-8 该文件将正常加载

When I edit a JS or CSS file and save it, the browser then turns around and detects illegal characters. When I view the file in the browser I see the diamond-question mark character which usually points to an encoding issue. I can open the file up in vim inside the VM and save it with :w ++enc=utf-8 and the file will load normally.

我试过主机和其他主机操作系统上的多个IDE和只能将其精确定位到事做流浪汉,安装的目录。我的IDE是没有问题的,因为我可以在本地运行的文件和他们的工作,或将其保存到远程计算机和文件。只有当我将它们保存到什么被安装在 /游民做我有一个问题。

I've tried multiple IDEs on the host machine and different host OSes, and can only pinpoint it to something to do with vagrant and the mounted directory. My IDEs aren't the problem as I can run the files locally and they work, or save them to a remote machine and the files work. Only when I save them to what gets mounted in /vagrant do I have a problem.

它是Apache或者其他的,我需要改变,以得到这个工作的OS的东西吗?

Is it Apache or something else in the OS that I need to change to get this to work?

推荐答案

今天早晨我有这个问题。在你的httpd.conf设置EnableSendfile来了。

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

如果你看看你的httpd.conf它说:​​如果你从NFS挂载的文件系统,请关闭它。在<一个href=\"http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile\">http://httpd.apache.org/docs/2.2/mod/core.html#enablesendfile它解释说:在默认情况下,当一个请求的处理需要一个文件内没有访问数据 - 例如,提供一个静态文件时 - Apache用于发送文件到而没有读取该文件,如果操作系统提供的文件内容支持它。

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

由于您的Windows主机都有一个NTFS文件系统,Linux来宾不能正常缓存,发送文件等Apache需要将文件发送文件本身。请求Apache的文件时,这可能会导致边际增速放缓,但它应该是微不足道的。

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.

这篇关于在颠沛流离的JS和CSS文件无法正常连接codeD时,保存在虚拟机以外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆