windows 如何在 Apache 2.2.17 上启用 mod_Gzip?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6304738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 08:27:03  来源:igfitidea点击:

How do I enable mod_Gzip on Apache 2.2.17?

windowsapachegzip

提问by Sarah Ogbonna

I'm working on windows7 64bit env.How should I enable gzip module on apache 2.2.17? And what are differences between mod_deflate and mod_gzip? thanks

我正在使用 windows7 64 位环境。我应该如何在 apache 2.2.17 上启用 gzip 模块?mod_deflate 和 mod_gzip 之间有什么区别?谢谢

回答by Karl-Bj?rnar ?ie

You can enable it like this in your apache config file, or .htaccess file if enabled

您可以在 apache 配置文件或 .htaccess 文件中启用它(如果启用)

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
</IfModule>

See: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

请参阅:http: //httpd.apache.org/docs/2.0/mod/mod_deflate.html

回答by Serga

mod_deflate module is shipped with Apache, but in order to use it, you should enable one in your httpd.conffile (it is initially commented out):

mod_deflate 模块随 Apache 一起提供,但为了使用它,您应该在httpd.conf文件中启用一个(它最初被注释掉):

LoadModule deflate_module modules/mod_deflate.so

After that just add following to the httpd.conf:

之后,只需将以下内容添加到httpd.conf

SetOutputFilter DEFLATE 
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript

For more tuning refer, as was mentioned: http://httpd.apache.org/docs/2.2/mod/mod_deflate.html

有关更多调整参考,如前所述:http: //httpd.apache.org/docs/2.2/mod/mod_deflate.html

回答by DevelRoot

There is no mod_gzipfor Apache 2.2x, as it is an Apache 1.3x module. Apache 2.2x has a only mod_deflate. GZip is the same DEFLATE plus a checksum and header/footer. As you can see here, Deflate is faster.

mod_gzipApache 2.2x没有,因为它是一个 Apache 1.3x 模块。Apache 2.2x 只有一个mod_deflate. GZip 是相同的 DEFLATE 加上校验和和页眉/页脚。正如你在这里看到的,放气速度更快。

回答by Stan S.

Also note that mod_filter needs to be loaded as well as mod_deflate (due to both being commented out by default):

另请注意,需要加载 mod_filter 和 mod_deflate(由于默认情况下两者都被注释掉):

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

Like the previous comment: After that just add following to the httpd.conf:

就像之前的评论:之后只需将以下内容添加到 httpd.conf:

SetOutputFilter DEFLATE 
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript

Tested on: Apache/2.4.10

测试:Apache/2.4.10

Note: mod_filter is required in 2.4, although in 2.2 that may not be the case.

注意:mod_filter 在 2.4 中是必需的,尽管在 2.2 中可能不是这种情况。