apache2.4.4启用deflate与gzip压缩

本文详细介绍了在Apache服务器中启用gzip压缩的过程,包括如何正确加载mod_deflate和mod_filter模块,以及如何配置指令以实现对特定文件类型进行压缩。通过实例演示了遇到错误时的排查步骤,最终成功解决了配置问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在看《高性能php应用开发》这本书,说道如何启用mod_deflate:

启用如下模块:

LoadModule deflate_module modules/mod_deflate.so

然后加入指令:

AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript

即可。

但是发现老是出错,

 Invalid command 'AddOutputFilterByType', perhaps misspelled or defined by a module not included in the server configuration 

去百度查看下,未果,之后发现官方有段话:

Invalid command 'AddOutputFilterByType', perhaps misspelled       or defined by a module not included in the server configuration        -AddOutputFilterByType       has moved from the core to mod_filter, which must be loaded.

原来,除了启用deflate之外,还要启用mod_filter,找到这句:

LoadModule filter_module modules/mod_filter.so

去除前面的分号,终于好了!

apache2.4开启gzip压缩

LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
<ifmodule mod_deflate.c> 
     DeflateCompressionLevel 9 
     AddOutputFilterByType   DEFLATE text/html text/plain text/xml application/x-httpd-php 
     AddOutputFilter         DEFLATE  html  htm  xml  php  css  js 
</ifmodule>


转载于:https://my.oschina.net/rookier/blog/390964

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值