![在 Apache 2.2 上无法运行 DEFLATE](https://linux22.com/image/652241/%E5%9C%A8%20Apache%202.2%20%E4%B8%8A%E6%97%A0%E6%B3%95%E8%BF%90%E8%A1%8C%20DEFLATE.png)
我发现我的服务器没有提供压缩页面。
使用这个答案,我在 httpd conf 文件中添加了以下内容:
# Declare a "gzip" filter, it should run after all internal filters like PHP or SSI
FilterDeclare gzip CONTENT_SET
# "gzip" filter can change "Content-Length", can not be used with range requests
FilterProtocol gzip change=yes;byteranges=no
# Enable "gzip" filter if "Content-Type" contains "text/html", "text/css" etc.
FilterProvider gzip DEFLATE resp=Content-Type $text/html
FilterProvider gzip DEFLATE resp=Content-Type $text/css
FilterProvider gzip DEFLATE resp=Content-Type $text/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/javascript
FilterProvider gzip DEFLATE resp=Content-Type $application/x-javascript
# Add "gzip" filter to the chain of filters
FilterChain gzip
接下来,我发布了
apachectl configtest
这产生了这个错误:
无效命令‘FilterDeclare’,可能是拼写错误或由服务器配置中未包含的模块定义
以下是httpd -l
Compiled in modules:
core.c
prefork.c
http_core.c
mod_so.c
我需要安装哪些模块才能使页面压缩正常工作?我正在运行 CentOS 6.6。
答案1
在 Centos 中mod_filter
默认情况下不会加载,您需要在httpd.conf
以下行中添加或取消注释:
LoadModule filter_module modules/mod_filter.so
不要忘记重新加载你的更改
service httpd graceful