简体   繁体   English

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

[英]How to enable GZip compression in XAMPP server

I am using xampp sever latest version to improve my web page performance. 我正在使用xampp sever最新版本来改善我的网页性能。

I have to enable Gzip in XAMPP. 我必须在XAMPP中启用Gzip。 How can it be done? 如何做呢?

You do compression by setting appropriate directive in apache. 您可以通过在apache中设置适当的指令来进行压缩。

It goes uncommenting the following lines in your apache conf file: C:\\xampp\\apache\\conf\\httpd.conf 它取消了你的apache conf文件中的以下行:C:\\ xampp \\ apache \\ conf \\ httpd.conf

if your xampp installation folder is C:\\xampp. 如果你的xampp安装文件夹是C:\\ xampp。

and these are the lines to be uncommented first: 这些是首先要取消注释的行:

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

that is to say, if they have # before them, you should remove them! 也就是说,如果他们之前有#,你应该删除它们!

Then put this at the end of your httpd.conf file: 然后将它放在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> 

Everything what is said above does not work on my XAMPP version 1.8.1 (php 5.4.7). 上面说的一切都不适用于我的XAMPP版本1.8.1(php 5.4.7)。

The only thing that works is to put on "On" instead of "Off" these line of the php.ini file: 唯一有效的方法是在php.ini文件的这一行上加上“On”而不是“Off”:

zlib.output_compression = On

Find apache\\conf\\httpd.conf 找到apache \\ conf \\ httpd.conf

uncomment the following line(remove #) 取消注释以下行(删除#)

LoadModule headers_module modules/mod_deflate.so

some versions may require you to comment out the following lines instead. 某些版本可能要求您注释掉以下行。

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

finally add this line to your .htaccess file. 最后将此行添加到.htaccess文件中。

SetOutputFilter DEFLATE

Not sure why you have this code: 不确定为什么你有这个代码:

LoadModule headers_module modules/mod_deflate.so

But that didn't work for me, it returned an APACHE error on Apache/2.4.3 (Win32): 但这对我没用,它在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.

I Had to use: 我必须使用:

LoadModule deflate_module modules/mod_deflate.so

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM