设为首页 收藏本站
查看: 838|回复: 0

[经验分享] apache编译参数

[复制链接]

尚未签到

发表于 2018-11-27 09:27:59 | 显示全部楼层 |阅读模式
  LINUX下为apache添加模块
  文本页面(htm/css/js等)启用压缩后,一般可以压缩70%左右。即50K的文件,实际只需传输15K到客户端,由客户端解压显示。另外,实践证明,启用Gzip压缩后,不会对搜索引擎收录有影响。在Apache1.3时代,有一个mod_gzip的模块,但  Apache2.x系列已经内置了Deflate模块,因此,只需要安装Deflate模块即可,由于在编译apache时没有加这些参数,只能另外添加安装:
  ============================================================
  一、mod_deflate.so安装过程:
  1、进入源码包
  [root@dns filters]#  pwd
  /home/redhat/httpd-2.2.15/modules/filters
  2、安装deflate  并添加到httpd.conf中
  [root@dns filters]# /usr/local/apache2/bin/apxs -i -c -a  mod_deflate.c
  apxs命令参数说明:
  -i  此选项表示需要执行安装操作,以安装一个或多个动态共享对象到服务器的modules目录中。
  -a  此选项自动增加一个LoadModule行到httpd.conf文件中,以激活此模块,或者,如果此行已经存在,则启用之。
  -A 与 -a  选项类似,但是它增加的LoadModule命令有一个井号前缀(#),即此模块已经准备就绪但尚未启用。
  -c  此选项表示需要执行编译操作。它首先会编译C源程序(.c)files为对应的目标代码文件(.o),然后连接这些目标代码和files中其余的目标代码文件(.o和.a),以生成动态共享对象dsofile  。如果没有指定 -o 选项,则此输出文件名由files中的第一个文件名推测得到,也就是默认为mod_name.so  。
  3、查看安装目录中的modules文件夹和httpd.conf文件
  [root@dns modules]#  ls
  httpd.exp libphp5.so mod_deflate.so
  在第56 行出现
  LoadModule deflate_module      modules/mod_deflate.so
  二、mod_headers.so安装过程:
  1、mod_headers.c  在源码包的modeules/metadata目录下面
  [root@dns metadata]#  pwd
  /home/redhat/httpd-2.2.15/modules/metadata
  [root@dns metadata]# ls  mod_headers.
  mod_headers.c    mod_headers.dsp mod_headers.exp  mod_headers.lo   mod_headers.o
  2、安装deflate 并添加到httpd.conf中
  [root@dns  metadata]# /usr/local/apache2/bin/apxs -i -a -c mod_headers.c
  [root@dns  modules]# ls
  httpd.exp libphp5.so mod_deflate.so  mod_headers.so
  在57行出有
  LoadModule  headers_module     modules/mod_headers.so
  如果是新安装apache,直接加上 --enable-headers  --enable-deflate  即可
  ====================================================================
  三、在httpd.conf中添加
  
  DeflateCompressionLevel 7
  AddOutputFilterByType  DEFLATE text/html text/plain text/xml       application/x-httpd-php
  AddOutputFilter DEFLATE js  css
  
  这样的做法可以压缩一般网页中会用到的html、xml、php、css、js等格式文档输出,减少资料传输量,减少网络带宽被吃掉的情形。
  DeflateCompressionLevel  指压缩程度的等级;从1到9  ,9是最高等级,据了解,这样做最高可以减少8成大小的传输量,最好也能节省一半;
  DeflateCompressionLevel预设可以采用6  这个数值,以维持用处理器效能与网页
  压缩品质的平衡
  http://summervast.blog.51cto.com/690507/330898  好文章
  http://blog.lizhigang.net/archives/36
  tar -xzvf httpd-2.2.8.tar.gz
  cd httpd-2.2.8
  编译参数一:
  ./configure --prefix=/usr/local/apache(默认只包含基本模块)
  echo "/usr/local/lib"  >> /etc/ld.so.conf
  ldconfig
  [root@test httpd-2.2.8]# /usr/local/apache/bin/apachectl -l
  Compiled in  modules:
  core.c
  mod_authn_file.c
  mod_authn_default.c
  mod_authz_host.c
  mod_authz_groupfile.c
  mod_authz_user.c
  mod_authz_default.c
  mod_auth_basic.c
  mod_include.c
  mod_filter.c
  mod_log_config.c
  mod_env.c
  mod_setenvif.c
  prefork.c
  http_core.c
  mod_mime.c
  mod_status.c
  mod_autoindex.c
  mod_asis.c
  mod_cgi.c
  mod_negotiation.c
  mod_dir.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_so.c
  ---------------------------------------
  [root@test httpd-2.2.8]# /usr/local/apache/bin/apachectl -M
  Loaded  Modules:
  core_module (static)
  authn_file_module  (static)
  authn_default_module (static)
  authz_host_module  (static)
  authz_groupfile_module (static)
  authz_user_module  (static)
  authz_default_module (static)
  auth_basic_module  (static)
  include_module (static)
  filter_module  (static)
  log_config_module (static)
  env_module (static)
  setenvif_module  (static)
  mpm_prefork_module (static)
  http_module (static)
  mime_module  (static)
  status_module (static)
  autoindex_module (static)
  asis_module  (static)
  cgi_module (static)
  negotiation_module (static)
  dir_module  (static)
  actions_module (static)
  userdir_module (static)
  alias_module  (static)
  so_module (static)
  Syntax OK
  编译参数二:
  ./configure --prefix=/usr/local/apache --with-mpm=worker  --enable-mods-shared=most --disable-userdir
  [root@test httpd-2.2.8]# /usr/local/apache/bin/apachectl -l
  Compiled in  modules:
  core.c
  worker.c
  http_core.c
  mod_so.c
  -------------------------------------------
  [root@test httpd-2.2.8]# /usr/local/apache/bin/apachectl -M
  Loaded  Modules:
  core_module (static)
  mpm_worker_module (static)
  http_module  (static)
  so_module (static)
  authn_file_module (shared)
  authn_dbm_module  (shared)
  authn_anon_module (shared)
  authn_dbd_module  (shared)
  authn_default_module (shared)
  authz_host_module  (shared)
  authz_groupfile_module (shared)
  authz_user_module  (shared)
  authz_dbm_module (shared)
  authz_owner_module  (shared)
  authz_default_module (shared)
  auth_basic_module  (shared)
  auth_digest_module (shared)
  dbd_module (shared)
  dumpio_module  (shared)
  ext_filter_module (shared)
  include_module  (shared)
  filter_module (shared)
  substitute_module  (shared)
  deflate_module (shared)
  log_config_module  (shared)
  logio_module (shared)
  env_module (shared)
  expires_module  (shared)
  headers_module (shared)
  ident_module (shared)
  setenvif_module  (shared)
  mime_module (shared)
  dav_module (shared)
  status_module  (shared)
  autoindex_module (shared)
  asis_module (shared)
  info_module  (shared)
  cgid_module (shared)
  dav_fs_module (shared)
  vhost_alias_module  (shared)
  negotiation_module (shared)
  dir_module  (shared)
  imagemap_module (shared)
  actions_module  (shared)
  speling_module (shared)
  alias_module (shared)
  rewrite_module  (shared)
  Syntax OK
  三、
  ./configure --prefix=/usr/local/apache --with-mpm=worker  --enable-mods-shared=most --disable-userdir --disable-speling
  省略相同的部分:
  .........
  dir_module (shared)
  imagemap_module  (shared)
  actions_module (shared)
  alias_module (shared)
  rewrite_module  (shared)
  Syntax OK
  基本(B)模块默认包含,必须明确禁用;扩展(E)/实验(X)模块默认不包含,必须明确启用。
  模块名称 状态 简要描述
  mod_actions (B) 根据特定的媒体类型或请求方法,激活特定的CGI脚本
  mod_alias (B)  提供从文件系统的不同部分到文档树的映射和URL重定向
  mod_asis (B) 发送自己包含HTTP头内容的文件
  mod_auth_basic  (B) 使用基本认证
  mod_authn_default (B) 在未正确配置认证模块的情况下简单拒绝一切认证信息
  mod_authn_file  (B) 使用纯文本文件为认证提供支持
  mod_authz_default (B)  在未正确配置授权支持模块的情况下简单拒绝一切授权请求
  mod_authz_groupfile (B)  使用纯文本文件为组提供授权支持
  mod_authz_host (B) 供基于主机名、IP地址、请求特征的访问控制
  mod_authz_user  (B) 基于每个用户提供授权支持
  mod_autoindex (B) 自动对目录中的内容生成列表,类似于”ls”或”dir”命令
  mod_cgi  (B) 在非线程型MPM(prefork)上提供对CGI脚本执行的支持
  mod_cgid (B)  在线程型MPM(worker)上用一个外部CGI守护进程执行CGI脚本
  mod_dir (B)  指定目录索引文件以及为目录提供”尾斜杠”重定向
  mod_env (B)  允许Apache修改或清除传送到CGI脚本和SSI页面的环境变量
  mod_filter (B)  根据上下文实际情况对输出过滤器进行动态配置
  mod_imagemap (B) 处理服务器端图像映射
  mod_include (B)  实现服务端包含文档(SSI)处理
  mod_isapi (B) 仅限于在Windows平台上实现ISAPI扩展
  mod_log_config (B)  允许记录日志和定制日志文件格式
  mod_mime (B)  根据文件扩展名决定应答的行为(处理器/过滤器)和内容(MIME类型/语言/字符集/编码)
  mod_negotiation (B)  提供内容协商支持
  mod_nw_ssl (B) 仅限于在NetWare平台上实现SSL加密支持
  mod_setenvif (B)  根据客户端请求头字段设置环境变量
  mod_status (B) 生成描述服务器状态的Web页面
  mod_userdir (B)  允许用户从自己的主目录中提供页面(使用”/~username”)
  mod_auth_digest (X)  使用MD5摘要认证(更安全,但是只有最新的浏览器才支持)
  mod_authn_alias (E)  基于实际认证支持者创建扩展的认证支持者,并为它起一个别名以便于引用
  mod_authn_anon (E)  提供匿名用户认证支持
  mod_authn_dbd (E) 使用SQL数据库为认证提供支持
  mod_authn_dbm (E)  使用DBM数据库为认证提供支持
  mod_authnz_ldap (E)  允许使用一个LDAP目录存储用户名和密码数据库来执行基本认证和授权
  mod_authz_dbm (E)  使用DBM数据库文件为组提供授权支持
  mod_authz_owner (E) 基于文件的所有者进行授权
  mod_cache (E)  基于URI键的内容动态缓冲(内存或磁盘)
  mod_cern_meta (E) 允许Apache使用CERN  httpd元文件,从而可以在发送文件时对头进行修改
  mod_charset_lite (X) 允许对页面进行字符集转换
  mod_dav (E)  允许Apache提供DAV协议支持
  mod_dav_fs (E) 为mod_dav访问服务器上的文件系统提供支持
  mod_dav_lock (E)  为mod_dav锁定服务器上的文件提供支持
  mod_dbd (E) 管理SQL数据库连接,为需要数据库功能的模块提供支持
  mod_deflate  (E) 压缩发送给客户端的内容
  mod_disk_cache (E) 基于磁盘的缓冲管理器
  mod_dumpio (E)  将所有I/O操作转储到错误日志中
  mod_echo (X) 一个很简单的协议演示模块
  mod_example (X)  一个很简单的Apache模块API演示模块
  mod_expires (E)  允许通过配置文件控制HTTP的”Expires:”和”Cache-Control:”头内容
  mod_ext_filter (E)  使用外部程序作为过滤器
  mod_file_cache (X) 提供文件描述符缓存支持,从而提高Apache性能
  mod_headers (E)  允许通过配置文件控制任意的HTTP请求和应答头信息
  mod_ident (E) 实现RFC1413规定的ident查找
  mod_info (E)  生成Apache配置情况的Web页面
  mod_ldap (E) 为其它LDAP模块提供LDAP连接池和结果缓冲服务
  mod_log_forensic  (E) 实现”对比日志”,即在请求被处理之前和处理完成之后进行两次记录
  mod_logio (E)  对每个请求的输入/输出字节数以及HTTP头进行日志记录
  mod_mem_cache (E) 基于内存的缓冲管理器
  mod_mime_magic  (E) 通过读取部分文件内容自动猜测文件的MIME类型
  mod_proxy (E)  提供HTTP/1.1的代理/网关功能支持
  mod_proxy_ajp (E) mod_proxy的扩展,提供Apache JServ  Protocol支持
  mod_proxy_balancer (E) mod_proxy的扩展,提供负载平衡支持
  mod_proxy_connect  (E) mod_proxy的扩展,提供对处理HTTP CONNECT方法的支持
  mod_proxy_ftp (E)  mod_proxy的FTP支持模块
  mod_proxy_http (E) mod_proxy的HTTP支持模块
  mod_rewrite (E)  一个基于一定规则的实时重写URL请求的引擎
  mod_so (E) 允许运行时加载DSO模块
  mod_speling (E)  自动纠正URL中的拼写错误
  mod_ssl (E) 使用安全套接字层(SSL)和传输层安全(TLS)协议实现高强度加密传输
  mod_suexec  (E) 使用与调用web服务器的用户不同的用户身份来运行CGI和SSI程序
  mod_unique_id (E)  为每个请求生成唯一的标识以便跟踪
  mod_usertrack (E)  使用Session跟踪用户(会发送很多Cookie),以记录用户的点击流
  mod_version (E)  提供基于版本的配置段支持
  mod_vhost_alias (E) 提供大批量虚拟主机的动态配置支持
  ================================================================
  ./configure --prefix=/usr/local/webserver/apache --enable-so --enable-dav  --with-mpm=worker
  貌似成静态的了
  ./configure --prefix=/usr/local/webserver/apache  --enable-so --enable-dav --enable-deflate=shared --enable-expires=shared  --enable-rewrite=shared --enable-mods-shared=most --with-mpm=worker  LDFLAGS="-L/usr/lib64 -L/lib64" --enable-lib64 --libdir=/usr/lib64  --with-mpm=worker
  错误如下:
  error while loading shared libraries: libiconv.so.2: cannot  open shared object file: No such file or directory
  以前编译运行是可以的,可能是不久前升级了iconv库影响。在/usr/local/lib下可以找到libiconv.so.2,把/usr/local/lib加到路径中也不行。
  在/etc/ld.so.conf中加一行/usr/local/lib,运行ldconfig。再运行apache,OK。
  ld.so.conf和ldconfig是维护系统动态链接库的。
  lamp性能优化好文章
  http://www.ibm.com/developerworks/cn/linux/l-tune-lamp-2.html
  其他文章:
  http://bbs.linuxtone.org/thread-912-1-1.html
  http://www.discuz.net/thread-722804-1-1.html
  http://bbs.linuxtone.org/thread-104-1-1.html
  http://bbs.linuxtone.org/thread-122-1-1.html
  -----------------------------------------
  http://bbs.chinaunix.net/viewthread.php?tid=544063&extra=&page=1
  http://www.cqumzh.cn/uchome/space.php?uid=13184&do=blog&id=203654
  http://hi.baidu.com/yanft/blog/item/e3f7b326f8171c1b8b82a132.html
  http://www.linuxforum.net/forum/printthread.php?Cat=&Board=web&main=445922&type=post
  http://hi.baidu.com/soshishang/blog/item/e5da4203d3d5bf034bfb51d6.html
  http://www.cnblogs.com/licheng/archive/2008/11/08/1329666.html
  http://bbs.chinaunix.net/viewthread.php?tid=875806
  http://www.svn8.com/svnpz/20080326/428.html
  http://blog.52ak.cn/article.asp?id=151


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-640134-1-1.html 上篇帖子: apache tomcat iis 下篇帖子: Apache 及 Tomcat 的結合
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表