Apache 2.x mod_deflate 压缩仅适用于 OSX
Apache2 成功地在我的 Mac 安装上传输预压缩内容。我可以使用像index.gz、textfile.gz 等文件,它们都可以在浏览器中正常加载。
但是,当我尝试在其他 Apache 环境(例如 Ubuntu 和 CentOS 安装)上创建相同的配置时,gzip 内容永远不会在浏览器中呈现;它始终作为文件下载。
这是 AddEncoding 指令配置成功从 OSX Apache 安装流式传输文件,特别是此处建议的更改:https://stackoverflow.com/ a/609051/1074464。如果我关闭这些指令,它将失败并推迟再次下载。如该示例所示,OSX 安装使用 /etc/apache2/httpd.conf 作为这些指令,但其他发行版使用 /etc/apache2/apache2.conf 及其许多包含的虚拟主机子文件。我已经在我能想到的几乎每个位置进行了 AddType 和 AddEncoding 更新,包括:
/etc/apache2/sites-enabled/000-default
/etc/apache2/httpd.conf
/etc/apache2/apache2.conf
/etc/apache/mods-enabled/mime.conf
正如您从猎枪故障排除方法中看到的那样,我不清楚我需要在哪里/是否/以什么顺序指定这些指令。我以为我已经覆盖了所有可能的位置,但也许还有另一个或者我在 Linux 系统上没有看到的指令正在踩我配置的位置?
TIA
Apache2 successfully streams pre-compressed content on my Mac's installation. I can use files like index.gz, textfile.gz, etc and they all load fine in a browser.
But when I try to create the same configuration on other Apache environments like Ubuntu and CentOS installs, the gzip content never renders in the browser; it's always downloaded as a file.
It's the AddEncoding directive config that succeeded in streaming files from the OSX Apache install, specifically the changes recommended here: https://stackoverflow.com/a/609051/1074464. If I turn off those directives, it will fail and defer to downloading again. As in that example, the OSX install uses /etc/apache2/httpd.conf for these directives, but the other distros use /etc/apache2/apache2.conf and its many includes of the virtual hosts sub files. I've made the AddType and AddEncoding updates in about every location I can think of including:
/etc/apache2/sites-enabled/000-default
/etc/apache2/httpd.conf
/etc/apache2/apache2.conf
/etc/apache/mods-enabled/mime.conf
As you can see from the shotgun troubleshoot approach I'm not clear on where/if/in what order I need to specify these directives. I thought I'd covered all possible locations, but maybe there is another or perhaps a directive I'm not seeing on the Linux systems is stepping on the ones I've configured?
TIA
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在逐个文件地比较工作安装和非工作安装之后,我在损坏的 Linux 安装的 /etc/mime.types 中找到了此条目:
评论解决了问题。
After comparing the working and non-working installs on virtually a file-by-file basis, I found this entry in the broken Linux install's /etc/mime.types:
Commenting resolved the issue.