apache 如何检查我的共享主机提供商是否安装了 mod_gzip?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1121211/
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 if my shared hosting provider has mod_gzip installed?
提问by Goran
Is there a way to check if my hosting provider has mod_gzip enabled? It's not mentioned in any info on the web site, nor there is a forum to contact other people about this problem. Thanks.
有没有办法检查我的托管服务提供商是否启用了 mod_gzip?网站上的任何信息中都没有提到它,也没有论坛可以就这个问题联系其他人。谢谢。
回答by Gumbo
You can check that with either PHP's apache_get_modulesor phpinfo.
您可以使用 PHPapache_get_modules或phpinfo.
If you want to compress your output, you might want to try the output buffer handler ob_gzhandler. It automatically determines what type of content encoding the browser will accept ("gzip", "deflate" or none at all) and will return its output accordingly. Just put ob_start('ob_gzhandler')at the start of your script file (before anything is put out) and it does the rest.
如果你想压缩你的输出,你可能想尝试输出缓冲区处理程序ob_gzhandler。它会自动确定浏览器将接受哪种类型的内容编码(“gzip”、“deflate”或根本不接受)并相应地返回其输出。只需放在ob_start('ob_gzhandler')脚本文件的开头(在任何内容发布之前),剩下的就交给它了。
Or you simply use Apache's mod_deflatethat even can compress static files that are directly passed through to the client.
或者您只需使用Apache 的 mod_deflate,它甚至可以压缩直接传递给客户端的静态文件。
回答by dustmachine
If you upload a tiny little PHP file to your server containing the following you can see all the output from phpinfo. Lots of interesting details.
如果您将一个包含以下内容的小型 PHP 文件上传到您的服务器,您可以看到 phpinfo 的所有输出。很多有趣的细节。
<?php
phpinfo();
?>
Searching the page for "Loaded Modules" should show all the modules that are loaded. Look for mod_deflatealso as that seems to be more common (comes with Apache 2.0 installs anyway). Performance? gzip might be more compress, deflate might be faster.
在页面上搜索“加载的模块”应该会显示所有加载的模块。寻找mod_deflate也因为这似乎更常见(无论如何都安装了 Apache 2.0)。表现?gzip 可能更压缩,deflate 可能更快。
回答by Flion
After reading the answers above I typed into command line
阅读上面的答案后,我输入了命令行
php -r "phpinfo();" | grep gzip
and it returned
它返回了
gzip compression => enabled
sweet!
甜的!

