Apache的动态编译和静态编译

  Apache的核心思想就是模块化,将不同的功能抽成模块,当我们需要某个功能的时候,加载对应的模块就可以了,问题来了,模块我们要如何加载?这里我们就需要讨论Apache的动态和静态编译了。

  动态编译即在编译的时候,通过使用--enable-mods-shared=[module] 或者--enable-[module]=shared指令来指定哪个【module】是动态动态编译;静态编译即不加以shared符号等修饰符修饰的;在静态模块中,Apache使用<ifmodule></ifmodule>来配置文件,而动态模块,Apache以loadmoule来加载模块,示例如下:

 

 1 #以下命令将默认以静态形式进行编译
 2 ./configure --prefix=/usr/local/apache2
 3 .
 4 .
 5 .
 6 
 7 [root@localhost bin]# pwd
 8 /usr/local/apache2/bin
 9 [root@localhost bin]# ./apachectl -l
10 Compiled in modules:
11   core.c
12   mod_authn_file.c
13   mod_authn_default.c
14   mod_authz_host.c
15   mod_authz_groupfile.c
16   mod_authz_user.c
17   mod_authz_default.c
18   mod_auth_basic.c
19   mod_include.c
20   mod_filter.c
21   mod_log_config.c
22   mod_env.c
23   mod_setenvif.c
24   prefork.c
25   http_core.c
26   mod_mime.c
27   mod_status.c
28   mod_autoindex.c
29   mod_asis.c
30   mod_cgi.c
31   mod_negotiation.c
32   mod_dir.c
33   mod_actions.c
34   mod_userdir.c
35   mod_alias.c
36   mod_so.c

 

 1 #以下命令会将除了核心模块外的其他模块编译成动态模块
 2 [root@localhost httpd-2.2.9]# ./configure -prefix=/usr/local/apache2 --enable-mods-shared=all
 3 .
 4 .
 5 .
 6 
 7 [root@localhost bin]# pwd
 8 /usr/local/apache2/bin
 9 [root@localhost bin]# ./apachectl -M
10 httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
11 Loaded Modules:
12  core_module (static)-->代表静态模块
13  mpm_prefork_module (static)
14  http_module (static)
15  so_module (static)
16  authn_file_module (shared)-->代表动态模块
17  authn_dbm_module (shared)
18  authn_anon_module (shared)
19  authn_dbd_module (shared)
20  authn_default_module (shared)
21  authz_host_module (shared)
22  authz_groupfile_module (shared)
23  authz_user_module (shared)
24  authz_dbm_module (shared)
25  authz_owner_module (shared)
26  authz_default_module (shared)
27  auth_basic_module (shared)
28  auth_digest_module (shared)
29  dbd_module (shared)
30  dumpio_module (shared)
31  ext_filter_module (shared)
32  include_module (shared)
33  filter_module (shared)
34  substitute_module (shared)
35  deflate_module (shared)
36  log_config_module (shared)
37  log_forensic_module (shared)
38  logio_module (shared)
39  env_module (shared)
40  mime_magic_module (shared)
41  cern_meta_module (shared)
42  expires_module (shared)
43  headers_module (shared)
44  ident_module (shared)
45  usertrack_module (shared)
46  unique_id_module (shared)
47  setenvif_module (shared)
48  version_module (shared)
49  mime_module (shared)
50  dav_module (shared)
51  status_module (shared)
52  autoindex_module (shared)
53  asis_module (shared)
54  info_module (shared)
55  cgi_module (shared)
56  dav_fs_module (shared)
57  vhost_alias_module (shared)
58  negotiation_module (shared)
59  dir_module (shared)
60  imagemap_module (shared)
61  actions_module (shared)
62  speling_module (shared)
63  userdir_module (shared)
64  alias_module (shared)
65  rewrite_module (shared)

 

 1 #以下命令会将以shared结尾的编译成动态模块,其他的编译成静态模块
 2 [root@localhost httpd-2.2.9]# ./configure -prefix=/usr/local/apache2 --enable-modules=all 
 3 --enable-cache=shared 
 4 --enable-cache=shared 
 5 --enable-mem-cache=shared 
 6 --enable-file-cache=shared
 7 --enable-rewrite=shared
 8 .
 9 .
10 .
11 [root@localhost bin]# pwd
12 /usr/local/apache2/bin
13 [root@localhost bin]# ./apachectl -M
14 httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
15 Loaded Modules:
16  core_module (static)
17  authn_file_module (static)
18  authn_dbm_module (static)
19  authn_anon_module (static)
20  authn_dbd_module (static)
21  authn_default_module (static)
22  authz_host_module (static)
23  authz_groupfile_module (static)
24  authz_user_module (static)
25  authz_dbm_module (static)
26  authz_owner_module (static)
27  authz_default_module (static)
28  auth_basic_module (static)
29  auth_digest_module (static)
30  dbd_module (static)
31  dumpio_module (static)
32  ext_filter_module (static)
33  include_module (static)
34  filter_module (static)
35  substitute_module (static)
36  deflate_module (static)
37  log_config_module (static)
38  log_forensic_module (static)
39  logio_module (static)
40  env_module (static)
41  mime_magic_module (static)
42  cern_meta_module (static)
43  expires_module (static)
44  headers_module (static)
45  ident_module (static)
46  usertrack_module (static)
47  unique_id_module (static)
48  setenvif_module (static)
49  version_module (static)
50  mpm_prefork_module (static)
51  http_module (static)
52  mime_module (static)
53  dav_module (static)
54  status_module (static)
55  autoindex_module (static)
56  asis_module (static)
57  info_module (static)
58  cgi_module (static)
59  dav_fs_module (static)
60  vhost_alias_module (static)
61  negotiation_module (static)
62  dir_module (static)
63  imagemap_module (static)
64  actions_module (static)
65  speling_module (static)
66  userdir_module (static)
67  alias_module (static)
68  so_module (static)
69  file_cache_module (shared)
70  cache_module (shared)
71  mem_cache_module (shared)
72  rewrite_module (shared)
73 Syntax OK

  默认情况下,Apache将几个核心的模块通过静态的方式编译到了文件中,我们可以通过命令apachectl -l来查看,静态编译的好处:一是可以提高运行效率,据不完全统计,静态编译进文件中的模块比动态加载的模块效率高出5%左右,但是比起动态模块来讲,在维护性方面就没有动态模块方便。

 

转载于:https://www.cnblogs.com/gongdaohai/p/7063423.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
资源包主要包含以下内容: ASP项目源码:每个资源包中都包含完整的ASP项目源码,这些源码采用了经典的ASP技术开发,结构清晰、注释详细,帮助用户轻松理解整个项目的逻辑和实现方式。通过这些源码,用户可以学习到ASP的基本语法、服务器端脚本编写方法、数据库操作、用户权限管理等关键技术。 数据库设计文件:为了方便用户更好地理解系统的后台逻辑,每个项目中都附带了完整的数据库设计文件。这些文件通常包括数据库结构图、数据表设计文档,以及示例数据SQL脚本。用户可以通过这些文件快速搭建项目所需的数据库环境,并了解各个数据表之间的关系和作用。 详细的开发文档:每个资源包都附有详细的开发文档,文档内容包括项目背景介绍、功能模块说明、系统流程图、用户界面设计以及关键代码解析等。这些文档为用户提供了深入的学习材料,使得即便是从零开始的开发者也能逐步掌握项目开发的全过程。 项目演示与使用指南:为帮助用户更好地理解和使用这些ASP项目,每个资源包中都包含项目的演示文件和使用指南。演示文件通常以视频或图文形式展示项目的主要功能和操作流程,使用指南则详细说明了如何配置开发环境、部署项目以及常见问题的解决方法。 毕业设计参考:对于正在准备毕业设计的学生来说,这些资源包是绝佳的参考材料。每个项目不仅功能完善、结构清晰,还符合常见的毕业设计要求和标准。通过这些项目,学生可以学习到如何从零开始构建一个完整的Web系统,并积累丰富的项目经验。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值