记录开启centos7.1下apache2.4开启deflate(gzip)网页压缩功能

1. 在apache根目录下输出函数 phpinfo();查看已加载的模块

 上图就没有mod_deflate.so模块,说明Server Root中也没有mod_deflate.so文件。 如果没有deflate模块,则需要重新编译

2.正常情况下都会默认安装mod_deflate.so模块。在phpinfo()的loaded Modules中看到有mod_deflate模块,在Server Root也就能找到。接下来在httpd的conf文件中设置,去掉filter和mod_deflate模块前的#号。  我的conf中没找到

3.在httpd.conf添加配置如下:

<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>

posted @ 2018-12-13 16:37  庹明志的IT博客  阅读(570)  评论(0编辑  收藏  举报