如何在XAMPP服务器中启用GZip压缩

时间:2011-08-09 08:26:37

标签: php windows apache xampp gzip

我正在使用xampp服务器最新版本来改善我的网页性能。

我必须在XAMPP中启用Gzip。怎么办呢?

4 个答案:

答案 0 :(得分:55)

您可以通过在apache中设置适当的指令来进行压缩。

它会取消注释apache conf文件中的以下行:     C:\ XAMPP \阿帕奇\ CONF \ httpd.conf中

如果你的xampp安装文件夹是C:\ xampp。

这些是首先要取消注释的行:

LoadModule headers_module modules/mod_deflate.so
LoadModule filter_module modules/mod_filter.so

也就是说,如果他们之前有#,你应该删除它们!

然后将它放在httpd.conf文件的末尾:

SetOutputFilter DEFLATE 

<Directory "C:/your-server-root/manual">  #any path to which you wish to apply gzip compression to!
    <IfModule mod_deflate.c>
        AddOutputFilterByType DEFLATE text/html  # or any file type you wish
    </IfModule>
</Directory> 

答案 1 :(得分:12)

上面说的所有内容都不适用于我的XAMPP版本1.8.1(php 5.4.7)。

唯一有效的方法是在php.ini文件的这一行上加上“On”而不是“Off”:

zlib.output_compression = On

答案 2 :(得分:9)

查找apache \ conf \ httpd.conf

取消注释以下行(删除#)

LoadModule headers_module modules/mod_deflate.so

某些版本可能会要求您注释掉以下行。

LoadModule headers_module modules/mod_headers.so
LoadModule deflate_module modules/mod_deflate.so

最后将此行添加到.htaccess文件中。

SetOutputFilter DEFLATE

答案 3 :(得分:0)

不确定为什么你有这个代码:

LoadModule headers_module modules/mod_deflate.so

但这对我没用,它在Apache / 2.4.3(Win32)上返回了一个APACHE错误:

12:57:10  [Apache]  Error: Apache shutdown unexpectedly.
12:57:10  [Apache]  This may be due to a blocked port, missing dependencies, 
12:57:10  [Apache]  improper privileges, a crash, or a shutdown by another method.

我必须使用:

LoadModule deflate_module modules/mod_deflate.so