千家信息网

如何进行Apache服务mod_deflate模块分析

发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,如何进行Apache服务mod_deflate模块分析,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。LAMP架构应用实战
千家信息网最后更新 2026年11月02日如何进行Apache服务mod_deflate模块分析

如何进行Apache服务mod_deflate模块分析,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

LAMP架构应用实战-Apache服务

mod_deflate压缩模块

今天来介绍下比较常用的模块mod_deflate压缩模块

一:mod_deflate模块介绍

mod_deflate压缩模块提供了DEFLATE输出过滤器,允许服务器将内容发送给客户端之前进行压缩,节省带宽资源

二:mod_deflate模块查看

直接编译安装查看如下

[root@Centos modules]# /application/apache/bin/apachectl -l|grep mod_deflate

mod_deflate.c

以DSO方式编译安装查看如下

[root@Centos modules]# ls -l|grep defla

-rwxr-xr-x. 1 root root 86591 Sep 18 15:26 mod_deflate.so

但是以上两种方式不能同时安装,否则会出现错误

[root@Centos conf]# /application/apache/bin/apachectl -M|grep deflate

deflate_module (shared)

查看帮助

[root@Centos httpd-2.4.23]# ./configure --help|grep deflate

--enable-deflate Deflate transfer encoding support

编译、或以DSO安装方式安装与前面的缓存模块安装相同,这里就不再介绍了

三:mod_deflate配置

配置前看下HTTP头的信息

[root@Centos modules]# curl -I http://blog.abc.com:9999/

HTTP/1.1 200 OK

Date: Sun, 18 Sep 2016 07:37:58 GMT

Server: Apache/2.4.23 (Unix)

Last-Modified: Fri, 09 Sep 2016 12:19:55 GMT

ETag: "1f-53c122a061992"

Accept-Ranges: bytes

Content-Length: 31

Cache-Control: max-age=31104000

Expires: Wed, 13 Sep 2017 07:37:58 GMT

Content-Type: text/html

备份并配置模块

[root@Centos conf]# cp httpd.conf httpd.conf.0918

[root@Centos conf]# vi httpd.conf

中间内容省略

DeflateCompressionLevel 9

SetOutputFilter DEFLATE

AddOutputFilterByType DEFLATE text/html text/plain /text/xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE text/css

"httpd.conf" 521L, 18903C written

语法检查与服务重启

[root@Centos conf]# /application/apache/bin/apachectl -t

Syntax OK

[root@Centos conf]# /application/apache/bin/apachectl graceful

[root@Centos conf]# lsof -i tcp:9999

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

httpd 2156 root 8u IPv6 16255 0t0 TCP *:distinct (LISTEN)

httpd 13911 daemon 8u IPv6 16255 0t0 TCP *:distinct (LISTEN)

httpd 13912 daemon 8u IPv6 16255 0t0 TCP *:distinct (LISTEN)

httpd 13913 daemon 8u IPv6 16255 0t0 TCP *:distinct (LISTEN)

[root@Centos conf]# ps -ef|grep http

root 2156 10 15:13 ? 00:00:00 /application/apache2.4.23/bin/httpd -k restart

daemon13911 2156 0 15:49 00:00:00 /application/apache2.4.23/bin/httpd -k restart

daemon 13912 2156 0 15:49 00:00:00 /application/apache2.4.23/bin/httpd -k restart

daemon 13913 2156 0 15:49 ?00:00:00 /application/apache2.4.23/bin/httpd -k restart

root 14003 1941 015:50 pts/0 00:00:00 grep http

测试配置内容

[root@Centos conf]# curl -I http://blog.abc.com:9999/deflate.html

HTTP/1.1 200 OK

Date: Sun, 18 Sep 2016 09:32:39 GMT

Server: Apache/2.4.23 (Unix)

Last-Modified: Sun, 18 Sep 2016 08:10:40 GMT

ETag: "309-53cc3bb2de520"

Accept-Ranges: bytes

Content-Length: 777

Vary: Accept-Encoding 出现这个提示表明已启用压缩

Cache-Control: max-age=31104000

Expires: Wed, 13 Sep 2017 09:32:39 GMT

Content-Type: text/html

把之前的配置内容注释掉

[root@Centos conf]# /application/apache/bin/apachectl -t

Syntax OK

[root@Centos conf]# /application/apache/bin/apachectl graceful

[root@Centos conf]# ps -ef |grep http

root 14492 1 0 17:03 ? 00:00:00 /application/apache2.4.23/bin/httpd -k restart

daemon 14998 14492 0 17:39 ? 00:00:00 /application/apache2.4.23/bin/httpd -k restart

daemon 14999 14492 0 17:39 ? 00:00:00 /application/apache2.4.23/bin/httpd -k restart

daemon 15000 14492 0 17:39 ?00:00:00 /application/apache2.4.23/bin/httpd -k restart

root 15083 148 0 17:39 pts/0 00:00:00 grep http

[root@Centos conf]# lsof -i tcp:9999

COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME

httpd 14492 root 8u IPv6 28964 0t0 TCP *:distinct (LISTEN)

httpd 14998 daemon 8u IPv6 28964 0t0 TCP *:distinct (LISTEN)

httpd 14999 daemon 8u IPv6 28964 0t0 TCP *:distinct (LISTEN)

httpd 15000 daemon 8u IPv6 28964 0t0 TCP *:distinct (LISTEN)

[root@Centos conf]# curl -I http://blog.abc.com:9999/deflate.html

HTTP/1.1 200 OK

Date: Sun, 18 Sep 2016 09:40:08 GMT

Server: Apache/2.4.23 (Unix)

Last-Modified: Sun, 18 Sep 2016 08:10:40 GMT

ETag: "309-53cc3bb2de520"

Accept-Ranges: bytes

Content-Length: 777

Cache-Control: max-age=31104000

Expires: Wed, 13 Sep 2017 09:40:08 GMT

Content-Type: text/html

发现没有配置的时候是不会出现相关提示内容

提示:如果编译安装后,主配置文件中没有加入deflate此模块,那么我们可以手要增加一个这样的模块

LoadModule deflate_module modules/mod_deflate.so

看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注行业资讯频道,感谢您对的支持。

模块 配置 内容 服务 编译 方式 帮助 提示 分析 清楚 相同 信息 同时 备份 实战 客户 客户端 对此 带宽 常用 数据库的安全要保护哪些东西 数据库安全各自的含义是什么 生产安全数据库录入 数据库的安全性及管理 数据库安全策略包含哪些 海淀数据库安全审计系统 建立农村房屋安全信息数据库 易用的数据库客户端支持安全管理 连接数据库失败ssl安全错误 数据库的锁怎样保障安全 互联网科技公司简介 互联网科技公司经营范围 湖南永感互联网科技有限公司 合肥互联网科技公司 科技大学互联网专业好不好 西藏七维空间互联网科技有限公司 天速互联网络科技有限公司 互联网校园科技培训 福建科技产业互联网发展 南平创想时代互联网科技有限公司 成都互联网科技公司工作好不好 哈尔滨屹滨互联网科技有限公司 晋城互联网科技 互联网科技圈年度人物 城市宝互联网科技有限公司 互联网科技数字货币 2021世界互联网领先科技成果发布 中国新注册互联网科技 安徽零酒互联网科技有限公司 六子台科技互联网展会 深圳市人人互联网科技有限公司 互联网科技卖菜 群盈汇互联网科技有限公司 黑科技 体验场景 互联网大会 杭州披云加互联网科技有限公司 宇信科技在杭州互联网排第几 广州互联网高科技取餐柜 宁波跨境商互联网科技有限公司 珠海东科互联网科技有限公司 华人运通互联网科技公司
0