【问题标题】:Apache + File on mounted folder = Corrupted fileApache + 已安装文件夹上的文件 = 损坏的文件
【发布时间】:2024-04-28 23:35:02
【问题描述】:

我们将 LAMP Ubuntu 16.04 (Apache 2.4.7) 迁移到带有 Ubuntu 20.04 (Apache 2.4.41) 的新版本。

两者都有一个安装在 /var/www/intranet/onyar 上的驱动器。

使用新的,如果我从这个安装的驱动器下载一个文件,它就会损坏。与旧的一起工作。如果我用旧服务器下载就可以了。如果我通过 samba 访问就可以了。

  • http://newserver/intranet/onyar/test.xls => 损坏
  • http://oldserver/intranet/onyar/test.xls => 好的
  • \\newserver\root\var\www\intranet\onyar\test.xls => 好的

所以 Apache 和挂载的驱动器之间似乎有问题?如果我尝试使用挂载驱动器 (http://newserver/intranet/test.xls) 外部的文件,它可以正常工作。

我用 txt、office 类型和 PDF 文件对其进行了测试,所有文件都已损坏。 HTML 文件有效!

我放了一个简单的“test.txt”文件,里面有字符串“hola”,然后用“http://newserver/intranet/onyar/test.txt”打开它,浏览器给了我这个:

Last-Modified: Thu, 12 Nov 2020 09:38:46 GMT
ETag: "4-5b3e5adb1be88"
Accept-Ranges: bytes
Content-Length: 4
Cache-Control: max-age=1209600
Expires: Thu, 26 Nov 2020 09:40:37 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/plain

holad_ip = dnsResolve(host);
    if (isInNet(resolved_ip, "127.0.0.1", "255.255.255.255") || isInNet(resolved_ip, "172.16.0

事实上,如果我 Ctrl+F5 hola (d_ip = ...) 之后的字符串有时会发生变化:

Last-Modified: Thu, 12 Nov 2020 09:38:46 GMT
ETag: "4-5b3e5adb1be88"
Accept-Ranges: bytes
Content-Length: 4
Cache-Control: max-age=1209600
Expires: Thu, 26 Nov 2020 09:57:01 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/plain

holar.</p>
<hr>
<address>Apache/2.4.41 (Ubuntu) Server at 10.80.160.178 Port 80</address>
</body></html>
p>The document h
Last-Modified: Thu, 12 Nov 2020 09:38:46 GMT
ETag: "4-5b3e5adb1be88"
Accept-Ranges: bytes
Content-Length: 4
Cache-Control: max-age=1209600
Expires: Thu, 26 Nov 2020 09:57:01 GMT
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/plain

holaIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document ha

这些结尾似乎来自其他文件!就像 Apache 不知道文件什么时候结束并放了一些其他的东西......

参考:

  • fstab: //onyar/dades /var/www/intranet/onyar cifs credentials=/root/.smbcredentials,file_mode=0775,dir_mode=0775,auto 0 0

【问题讨论】:

    标签: apache ubuntu mount corruption


    【解决方案1】:

    我好像受到了这个bug的影响:https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900821

    对我来说,解决方案是将其放入 /etc/apache2/apache2.conf:

    <Directory "/var/www/intranet/onyar">
      EnableMMAP Off
    </Directory>
    

    【讨论】:

      最近更新 更多