我知道我的网站没有发送数据gzipped。 我testing使用像http://www.gidnetwork.com/tools/gzip-test.php网站
现在我想知道,如果Apache编译与GZIP模块或不。 在我提供压缩内容的代码之前,我想testing一下在我的apache服务器上是否启用了gzip,或者是否需要构build它。 我如何testing。 我如何把一个debugging语句,将出现在Apache日志。 我相信我可以做这样的事情,但不知道。
<IfModule mod_gzip.c> log('apache is configured with gzip. no need to install it') </IfModule>
什么代码将代替日志,以便我可以在apache日志中看到消息。 另外我怎样才能写else语句,以便我得到一个消息。
这是我的apache.conf
# Include module configuration: Include /etc/apache2/mods-enabled/*.load Include /etc/apache2/mods-enabled/*.conf # Include all the user configurations: Include /etc/apache2/httpd.conf # Include ports listing Include /etc/apache2/ports.conf
这是启用mods的目录中的项目列表
root@me:/etc/apache2/mods-enabled# ls alias.conf authn_file.load authz_host.load autoindex.load dir.load mime.load setenvif.conf status.load alias.load authz_default.load authz_user.load cgi.load env.load negotiation.conf setenvif.load auth_basic.load authz_groupfile.load autoindex.conf dir.conf mime.conf negotiation.load status.conf
尝试从命令行运行:
apache2 -l
这应该给你的模块内置到Apache的列表。 更可能你会有gzip作为额外的可加载模块mod_deflate.so
– 检查是否有任何.load加载这一个。
如果你使用debian'ish发行版(好像是这样),只需要从mods-deflate.load和deflate.conf启用mods-enabled:
cd /etc/apache2/mods-enabled/ ln -s ../mods-available/deflate.load ln -s ../mods-available/deflate.conf
并重新加载apache2
/etc/init.d/apache2 reload
检查输出:
httpd -M 2<&1 | grep gzip
?
我假设阿帕奇2 …..只是因为放气模块存在,并不一定意味着输出压缩发生。 有必要在希望输出的位置添加指令来进行gzip压缩:
SetOutputFilter DEFLATE
还有其他选项,以便只有特定types的文件也被压缩。
我build议你可以看看http://httpd.apache.org中的deflate模块描述。