apache2.4.4启用deflate与gzip压缩

今天在看《高性能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>


你可能感兴趣的:(apache2.4.4启用deflate与gzip压缩)