Pages

Monday, 30 January 2012

开启Apache的Gzip支持




首先,你可以先检查一下你是否已经开启了Gzip压缩支持:
http://tool.itlearner.com/gzip/

开启Apache支持的操作如下:
1 登陆SHH
2 在SHH执行下列代码
chattr -V -i /etc/httpd/conf/httpd.conf;
echo ‘LoadModule deflate_module modules/mod_deflate.so’ >> /etc/httpd/conf/httpd.conf
echo ‘AddOutputFilterByType DEFLATE text/html text/php text/png text/jpg text/plain text/css text/xml text/javascript’ >> /etc/httpd/conf/httpd.conf
echo ‘DeflateCompressionLevel 9′ >> /etc/httpd/conf/httpd.conf
echo ‘SetOutputFilter DEFLATE’ >> /etc/httpd/conf/httpd.conf
chattr -V +i /etc/httpd/conf/httpd.conf;
service httpd restart;

这段代码是我用于Kloxo脚本的,个别情况可能不同,大家自己稍做修改。

或者SFTP打开/etc/httpd/conf/httpd.conf写入下列信息

LoadModule deflate_module modules/mod_deflate.so
AddOutputFilterByType DEFLATE text/html text/php text/png text/jpg text/plain text/css text/xml text/javascript
DeflateCompressionLevel 9
SetOutputFilter DEFLATE

然后重启Apache即可:
service httpd restart

No comments:

Post a Comment