VirtualBox for Apache 中的共享文件夹

发布于 2024-11-14 21:45:16 字数 459 浏览 2 评论 0原文

我的主机是 ArchLinux,我在 CentOS 来宾中运行 Apache。我有虚拟主机配置和共享文件夹中的所有站点代码。为了能够将虚拟主机配置放在共享文件夹中,我将共享文件夹安装为 apache:apache。

shared    /mnt/shared    vboxsf    defaults,uid=48,gid=48  0 0

当我在主机中编辑文件时,Apache 将始终开始发送带有尾随字符的旧版本文件。在 vim 中,它们显示为 ^@,所以我猜它们是空字符。空字符的数量与我所做的更改数量有关,即使我编辑第一行,空字符也会显示在末尾。如果我推测的话,这看起来像是一个糟糕的差异。

如果我停止 httpd、umount、重新安装并启动 httpd,文件看起来不错。仅重新启动 httpd 没有帮助。

我将如何调试安装? /var/log 中没有任何内容让我惊讶。

My host machine is ArchLinux and I'm running Apache in a CentOS guest. I have the vhost configuration and all the site code in a shared folder. To be able to put the vhost configuration in a shared folder I mounted the shared folder as apache:apache.

shared    /mnt/shared    vboxsf    defaults,uid=48,gid=48  0 0

When I'm editing files in the host, Apache will consistently start sending old versions of the file with trailing characters. In vim, they show up as ^@, so I guess they're null characters. The number of null characters is related to the number of changes I make even if I edit the first line, null characters show up at the end. If I were to speculate, it looks like a bad diff.

If I stop httpd, umount, remount, and start httpd the file looks fine. Just restarting httpd doesn't help.

How would I go about debugging the mount? Nothing jumped out at me in /var/log.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

深白境迁sunset 2024-11-21 21:45:16

我错了;它发生在其他地方,但我注意到它仅适用于 .css 和 .js 文件。经过搜索,我找到了这篇文章,其中讨论了 vboxsf 的问题和小文件。

解决办法是在Apache中设置

    EnableSendfile off

I was wrong; it was happening elsewhere but I noticed that it was only with .css and .js files. A search led me to this post which talks about a problem with vboxsf and small files.

The solution is to set, in Apache

    EnableSendfile off
上课铃就是安魂曲 2024-11-21 21:45:16

lighttpd 上,解决方案是将以下行添加到 lighttpd.conf

server.network-backend = "writev"

请参阅:从 Virtualbox 共享文件夹提供服务时 Lighttpd 损坏

On lighttpd the solution is to add the below line to lighttpd.conf

server.network-backend = "writev"

See: Lighttpd broken when serving from Virtualbox shared folder

新人笑 2024-11-21 21:45:16

回答具体问题“我如何调试挂载”:(

以下是释义,基于我刚刚对 Virtualbox 中相同错误引起的问题进行的调查,但使用不同的 Web 服务器

)问题出在 Apache 如何读取虚拟主机内的文件的某个地方,我会在虚拟主机内使用“strace -p”来记录 Apache 的系统调用。

在跟踪时,仅请求一个被截断/损坏的文件。

仔细的诊断将表明它正确地统计了文件以获得其长度。然后它使用 sendfile 系统调用为其提供服务。基本上确认 sendfile 行为异常,这意味着它一定是虚拟机中的错误。

搜索“sendfile virtualbox”会发现这些错误。

https://www.virtualbox.org/ticket/9069
https://www.virtualbox.org/ticket/12597

To answer the specific question "how do I go about debugging the mount":

(the below is paraphrasing, based on an investigation I just did into a problem caused by the same bug in Virtualbox, but with a different web server)

After diagnosing the problem is happening somewhere in how Apache reads files inside the virtual host, I would use "strace -p" inside the virtual host to log system calls by Apache.

While stracing, request just the one truncated/corrupted file.

Careful diagnosis will reveal that it is correctly stat'ing the file to get its length. And then it is serving it using the sendfile syscall. Basically confirming sendfile is misbehaving, meaning it must be a bug in the virtual machine.

Searching for "sendfile virtualbox" takes you to these bugs.

https://www.virtualbox.org/ticket/9069
https://www.virtualbox.org/ticket/12597

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文