原文:https://book.2cto.com/201304/19620.html

当configure执行成功时会生成objs目录,并在该目录下产生以下目录和文件:
|---ngx_auto_headers.h
|---autoconf.err
|---ngx_auto_config.h
|---ngx_modules.c
|---src
|    |---core
|    |---event
|    |    |---modules
|    |---os
|    |    |---unix
|    |    |---win32
|    |---http
|    |    |---modules
|    |    |      |---perl
|    |---mail
|    |---misc
|---Makefile

上述目录和文件介绍如下。

1)src目录用于存放编译时产生的目标文件。

2)Makefile文件用于编译Nginx工程以及在加入install参数后安装Nginx。

3)autoconf.err保存configure执行过程中产生的结果。

4)ngx_auto_headers.h和ngx_auto_config.h保存了一些宏,这两个头文件会被src/core/ngx_config.h及src/os/unix/ngx_linux_config.h文件(可将“linux”替换为其他UNIX操作系统)引用。

5)ngx_modules.c是一个关键文件,我们需要看看它的内部结构。一个默认配置下生成的ngx_modules.c文件内容如下:
#include <ngx_config.h>
#include <ngx_core.h>

ngx_module_t *ngx_modules[] = {
    &ngx_core_module,
    &ngx_errlog_module,
    &ngx_conf_module,
    &ngx_events_module,
    &ngx_event_core_module,
    &ngx_epoll_module,
    &ngx_http_module,
    &ngx_http_core_module,
    &ngx_http_log_module,
    &ngx_http_upstream_module,
    &ngx_http_static_module,
    &ngx_http_autoindex_module,
    &ngx_http_index_module,
    &ngx_http_auth_basic_module,
    &ngx_http_access_module,
    &ngx_http_limit_zone_module,
    &ngx_http_limit_req_module,
    &ngx_http_geo_module,
    &ngx_http_map_module,
    &ngx_http_split_clients_module,
    &ngx_http_referer_module,
    &ngx_http_rewrite_module,
    &ngx_http_proxy_module,
    &ngx_http_fastcgi_module,
    &ngx_http_uwsgi_module,
    &ngx_http_scgi_module,
    &ngx_http_memcached_module,
    &ngx_http_empty_gif_module,
    &ngx_http_browser_module,
    &ngx_http_upstream_ip_hash_module,
    &ngx_http_write_filter_module,
    &ngx_http_header_filter_module,
    &ngx_http_chunked_filter_module,
    &ngx_http_range_header_filter_module,
    &ngx_http_gzip_filter_module,
    &ngx_http_postpone_filter_module,
    &ngx_http_ssi_filter_module,
    &ngx_http_charset_filter_module,
    &ngx_http_userid_filter_module,
    &ngx_http_headers_filter_module,
    &ngx_http_copy_filter_module,
    &ngx_http_range_body_filter_module,
    &ngx_http_not_modified_filter_module,
    NULL
};

ngx_modules.c文件就是用来定义ngx_modules数组的。

ngx_modules是非常关键的数组,它指明了每个模块在Nginx中的优先级,当一个请求同时符合多个模块的处理规则时,将按照它们在ngx_modules数组中的顺序选择最靠前的模块优先处理。对于HTTP过滤模块而言则是相反的,因为HTTP框架在初始化时,会在ngx_modules数组中将过滤模块按先后顺序向过滤链表中添加,但每次都是添加到链表的表头,因此,对HTTP过滤模块而言,在ngx_modules数组中越是靠后的模块反而会首先处理HTTP响应(参见第6章及第11章的11.9节)。

因此,ngx_modules中模块的先后顺序非常重要,不正确的顺序会导致Nginx无法工作,这是auto/modules脚本执行后的结果。读者可以体会一下上面的ngx_modules中同一种类型下(第8章会介绍模块类型,第10章、第11章将介绍的HTTP框架对HTTP模块的顺序是最敏感的)各个模块的顺序以及这种顺序带来的意义。

可以看出,在安装过程中,configure做了大量的幕后工作,我们需要关注在这个过程中Nginx做了哪些事情。configure除了寻找依赖的软件外,还针对不同的UNIX操作系统做了许多优化工作。这是Nginx跨平台的一种具体实现,也体现了Nginx追求高性能的一贯风格。

configure除了生成Makefile外,还生成了ngx_modules.c文件,它决定了运行时所有模块的优先级(在编译过程中而不是编码过程中)。对于不需要的模块,既不会加入ngx_modules数组,也不会编译进Nginx产品中,这也体现了轻量级的概念。

转载:configure生成的文件(1.5.3)《深入理解Nginx》(陶辉)的更多相关文章

  1. 转载:小结(1.7)《深入理解Nginx》(陶辉)

    原文:https://book.2cto.com/201304/19622.html 本章介绍了Nginx的特点以及在什么场景下需要使用Nginx,同时介绍了如何获取Nginx以及如何配置.编译.安装 ...

  2. 转载:2.2.1 块配置项《深入理解Nginx》(陶辉)

    原文:https://book.2cto.com/201304/19626.html 块配置项由一个块配置项名和一对大括号组成.具体示例如下:events {-} http { upstream ba ...

  3. 清理configure脚本生成的文件

    今天在修改dovecot的代码时遇到一个问题,需要重新执行configure脚本,想先把之前configure生成的文件删除掉. 结果看了configure --help没有找到可以用的命令,最后搜了 ...

  4. make clean 清除之前编译的可执行文件及配置文件。 make distclean 清除所有生成的文件。

    https://blog.csdn.net/bb807777/article/details/108302105 make clean 清除之前编译的可执行文件及配置文件.make distclean ...

  5. 使用automake等命令自动生成Makefile文件 (转载)

    使用automake等命令自动生成Makefile文件   Linux下编程时,为了方便编译,往往使用Makefile文件自动完成编译,但是Makefile文件本身的书写十分复杂,规则很多.好在Lin ...

  6. 【转载】Linux下编辑生成.mo文件

    转载自:http://www.hackbase.com/tech/2012-02-27/65972.html 编辑生成.mo文件 我们在弄网站的时候很可能会接触到.mo和.po文件..po文件是GNU ...

  7. 使用GDB生成coredump文件【转载】

    本文转载自: http://blog.csdn.net/sky_qing/article/details/8548989 如果在测试过程中遇到某个进程的CPU利用率过高或者卡死而需要去调试该进程时,可 ...

  8. 转载:python生成以及打开json、csv和txt文件

    原文地址:https://blog.csdn.net/weixin_42555131/article/details/82012642 生成txt文件: mesg = "hello worl ...

  9. 使用log4net生成日志文件

    (一)使用log4net生成日志文件   1.引入log4net.dll 1.1 Nuget安装 或 http://logging.apache.org/log4net/下载log4net的源代码,编 ...

随机推荐

  1. CodeChef题目选讲

    https://wenku.baidu.com/view/2445a0322f60ddccda38a023.html 关键点:不超过7条 根据咕咕原理,所以答案最少是N/7;(N小于49就暴力) 随机 ...

  2. 【codevs4829】数字三角形++

    题目大意:给定一个数字三角形,求从 (1,1) 到第 N 行的路径经过的权值之和加上该路径上任意一个点的权值之和的最大值. 题解:任意加一条路径上的某个值,可以看成是多了一次选择的权利,即:在每次经过 ...

  3. 【洛谷P1854】花店橱窗 线性dp+路径输出

    题目大意:给定 N 个数字,编号分别从 1 - N,M 个位置,N 个数字按照相对大小顺序放在 M 个位置里,每个数放在每个位置上有一个对答案的贡献值,求一种摆放方式使得贡献值最大. 题解:一道典型的 ...

  4. ffmpeg在asp.net 视频转换

    ffmpeg是一个源于Linux的工具软件,是FLV视频转换器,可以轻易地实现FLV向其它格式avi.asf. mpeg的转换或者将其它格式转换为flv.在视频播客中,我们通常使用它把我们上传的视频转 ...

  5. ELK技术实战-安装Elk 5.x平台

    ELK技术实战–了解Elk各组件   转载  http://www.ywnds.com/?p=9776 ELK技术实战-部署Elk 2.x平台 ELK Stack是软件集合Elasticsearch. ...

  6. Prometheus Redis_exporter

    Redis 下载redis_exporter wget https://github.com/oliver006/redis_exporter/releases/download/v0.15.0/re ...

  7. python自动化运维之路~DAY7

    python自动化运维之路~DAY7 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.客户端/服务器架构 C/S 架构是一种典型的两层架构,其全称是Client/Server,即 ...

  8. HBase基础之常用过滤器hbase shell操作

    创建表 create 'test1', 'lf', 'sf' lf: column family of LONG values (binary value) -- sf: column family ...

  9. Bandicam录制视频

    我已经录制了一个视频,关于怎么录制视频的,原画画质的嘻嘻.视频地址  http://www.tudou.com/programs/view/T7xzG1CgsD4 ------------------ ...

  10. window下nginx负载均衡简单配置-----权重的实现

    下面介绍一个在window下的nginx的负载均衡配置. 需要你在你的电脑上跑两个tomcat.一个8080,一个9080. 需要一个nginx服务器. 需要修改本机的host 注意:我们这里配置不会 ...