需要在apache配置文件(默认路径/var/www/conf/httpd.conf)加入以下配置:
DeflateCompressionLevel 9
AddOutputFilterByType DEFLATE
text/html text/plain text/xml application/x-httpd-php
AddOutputFilter
DEFLATE js css
然后重启apache
# /var/www/bin/apachectl
restart
重启完毕即可生效。