如何检查 apache 中是否启用了 mod_deflate?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/970151/
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
how to check mod_deflate is enabled in apache?
提问by omg
Is there a command line command that can tell whether or not mod deflate is running on Apache?
是否有命令行命令可以判断 mod deflate 是否在 Apache 上运行?
回答by Juri Glass
It is probably to late, but here we go.
可能为时已晚,但我们走了。
mod_deflate is enabled per default. To be sure, try
默认情况下启用 mod_deflate。可以肯定的是,尝试
debian / ubuntu:
apache2ctl -t -D DUMP_MODULES
Debian / Ubuntu:
apache2ctl -t -D DUMP_MODULES
CentOS:
httpd -t -D DUMP_MODULES
CentOS:
httpd -t -D DUMP_MODULES
and look if there is a deflate_module.
并查看是否有 deflate_module。
回答by dicroce
You can verify mod_deflate with this site:
您可以使用此站点验证 mod_deflate:
My site gets a nice little report that shows I'm saving 81% of my bandwidth!
我的网站收到一份不错的小报告,显示我节省了 81% 的带宽!
回答by karim79
You'll want to make sure the following line is present (and not commented out) in your apache configuration (httpd.conf):
您需要确保在您的 apache 配置 (httpd.conf) 中存在以下行(并且未注释掉):
LoadModule deflate_module modules/mod_deflate.so
The commented out version looks like:
注释掉的版本如下所示:
# LoadModule deflate_module modules/mod_deflate.so
Then to have it deflate files as they are served, you'll need a line in your .htaccess, like this:
然后让它在提供文件时对其进行压缩,您需要在 .htaccess 中添加一行,如下所示:
AddOutputFilterByType DEFLATE text/html text/css text/plain text/xml application/x-javascript
回答by digitalpardoe
I agree with the comments 'in what context' but to cover all bases (in addition to the other responses) you may also be able to run;
我同意“在什么情况下”的评论,但要涵盖所有基础(除了其他响应),您也可以运行;
a2enmod deflate
This should work on many servers that run Apache (especially Debian based ones), in the event the module is already enabled the command will tell you, if the module isn't enabled the command will enable it. It may also tell you that the module doesn't exist in which case you will need to install it.
这应该适用于许多运行 Apache 的服务器(尤其是基于 Debian 的服务器),如果模块已经启用,命令会告诉你,如果模块没有启用,命令会启用它。它也可能告诉您该模块不存在,在这种情况下您需要安装它。
回答by Edouard Kombo
Like said, we need precisions.
就像说的,我们需要精度。
If you're using debian, you can enable this mode like this.
如果您使用的是 debian,则可以像这样启用此模式。
//List all available mods
cd /etc/apache2/mods-avaliable
//Enable module - if you need to enable another module, just replace "deflate"
a2enmod deflate
//restart apache
service apache2 restart
//Check that module is effectively enabled
cd /etc/apache2/mods-enabled
ls -al
That's all for linux debian environment.
这就是 linux debian 环境的全部内容。

