Apache开启gzip压缩模块

0 ~o~

         Apache开启gzip压缩功能需要用到模块mod_deflate.so,你可以到%Apache安装路径%/modules文件夹下找到mod_deflate.so这样一个文件。在 %Apache安装路径%/conf 下的httpd.conf文件里面是没有加载这一模块的,所以你必须手动进行配置,在httpd.conf文件里面添加上以下内容:
#加载mod_deflate.so模块
LoadModule deflate_module modules/mod_deflate.so
#对text/html text/php text/png text/jpg text/plain text/css text/xml text/javascript
#启用GZIP压缩
AddOutputFilterByType DEFLATE text/html text/php text/png text/jpg text/plain text/css text/xml text/javascript
#压缩级别 9 性能最佳
DeflateCompressionLevel 9
#启用deflate模块对本站点的所有输出进行GZIP压缩
SetOutputFilter DEFLATE

最后重启Apache就可以了。。。

下面摘抄一下网上介绍的在linux下开启gzip压缩功能的文章内容:
而如果是 Linux/Unix 操作系统,如果你没有在编译安装的过程中将所需要的两个模块 mod_deflate 和 mod_headers 编译进去的话,那就稍微有点麻烦,首先我们先看如何在编译安装 Apache 过程中也同时编译这两个模块,请在执行 configure 程序时增加两个参数分别是:

# ./configure –enable-deflate –enable-headers
这样在编译完 Apache 后就可以直接在 httpd.conf 中启用并配置 deflate 模块了,配置的方法跟 Windows 平台下是相同的。
如果说您的 Apache 已经在运行了,不想再重新编译一次,那也可以选择只编译 deflate 模块所需的文件 mod_deflate.c 和 mod_headers.c。这两个文件位于 {apache-src}/modules/filters/ 目录下(其中 {apache-src} 为 apache 源文件所在的目录)。使用如下命令来单独编译这两个源文件。

# {apache-bin}/apxs -i -a -c {apache-src}/modules/filters/mod_deflate.c
# {apache-bin}/apxs –i –a –c {apache-src}/modules/filters/mod_headers.c
When install the header module the src directory is {apache-src}/modules/metadata/mod_headers.c
So we need change the command as follows:{apache-bin}/apxs -i -a -c {apache-src}/modules/metadata/mod_headers.c

其中 {apache-bin} 为 Apache 安装目录下的 bin 目录,接下来在 httpd.conf 直接配置该模块即可。
很多时候你在单独编译 deflate 模块的时候可能会碰到编译错误,提示是:
Cannot load /opt/apache/modules/mod_deflate.so into server: /opt/apache/modules/mod_deflate.so: undefined symbol: deflate
解决的方法如下:
编辑 /usr/local/apache2/bin/apr-config 文件修改其中的 LDFLAGS 值为 “-lz”,然后再重新编译 mod_deflate 模块,apxs -ica mod_deflate.c 即可。
为了省却不必要的麻烦,请尽量在编译安装时直接加上 –enable-deflate –enable-headers 参数。

启动Apache出错解决

0 ~o~

重新启动Apache服务器:
[root@cisco /]# service httpd restart
显示出错:
Starting httpd: (13)Permission denied: make_sock: could not bind to address [::]:81
no listening sockets available, shutting down
Unable to open logs

解决方法:禁用selinux
1) setenforce 0
2) 重新启动apache

Centos卸载自带apache问题解决

0 ~o~

1、[root@localhost etc]# rpm -qa|grep httpd,查看与httpd相关软件包。
httpd-2.2.3-11.el5_2.centos.4
2、然后删除httpd:
[root@localhost etc]# rpm -e httpd
出现问题:
error: Failed dependencies:
httpd >= 2.2.0 is needed by (installed) gnome-user-share-0.10-6.el5.i386
3、还有一个相关的软件包没有删除,清除之,即:
[root@localhost etc]# rpm -e gnome-user-share
5、再删除httpd
[root@localhost etc]# rpm -e httpd

#可以使用参数–nodeps的意思就是不管各个程序包间的依赖关系。
[root@localhost etc]#rpm -e –nodeps httpd //这样不需要删除gnome-user-share了.