CentOS 7中Apache的优化与配置(3)

注意:如果启动apache提示httpd: Syntax error on line 105 of /apache/conf/httpd.conf: Cannot load modules/mod_deflate.so into server: /apache/modules/mod_deflate.so: undefined symbol: inflate

则说明deflate模块没有找到zlib的库,可以先安装zlib,zlib-devel

yum install zlib zlib-devel

然后手动在httpd.conf下 加入以下命令

LoadFile /usr/lib64/libz.so  ##libz.so为deflate压缩模块所需要的库文件

<ifmodule mod_deflate.c>

DeflateCompressionLevel 9 

SetOutputFilter DEFLATE

DeflateFilterNote Input instream

DeflateFilterNote Output outstream

DeflateFilterNote Ratio ratio

AddOutputFilterByType    DEFLATE    text/html    text/plain    text/xml    text/css    text/javascript  application/xhtml+xml  application/xml    application/rss+xml    application/atom_xml    application/x-javascript      application/x-httpd-php    image/svg+xml    image/gif    image/png      image/jpe    image/swf    image/jpeg    image/bmp    application/javascript   

</ifmodule>

DeflateCompressionLevel 9 ###压缩等级(1-9),等级越大效率越高,但同时消耗的CPU也高,根据具体情况调优,也可以设置为6来平衡CPU及压缩质量

AddOutputFilterByType  ##仅压缩限制特定的MIME类型文件

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/36ec44e04bab0a529dc9f495d556f48a.html