首先编辑php.ini,修改zlib.output_compression
为On
然后编辑httpd.conf,取消注释以下两个模块
LoadModule deflate_module modules/mod_deflate.so
LoadModule filter_module modules/mod_filter.so
接下来在httpd.conf文件最下面加入:
SetOutputFilter DEFLATE
# Set the path to the directory where you wish to apply the gzip compression
# Usually you would like to apply that to the entire htdocs folder, but you can change it
<Directory "C:/xampp/htdocs">
<IfModule mod_deflate.c>
# Add any file type you want
AddOutputFilterByType DEFLATE text/html
</IfModule>
</Directory>
C:/xampp/htdocs为你要开启gzip压缩的web目录,改为你自己的目录即可
开启之后,我的网站首页打开速度对比

加载内容和时间减少一半