Nginx如何编译连接

这篇文章将为大家详细讲解有关Nginx如何编译连接,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

我们提供的服务有:成都网站设计、网站建设、微信公众号开发、网站优化、网站认证、海沧ssl等。为超过千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的海沧网站制作公司

nginx 组织过程

  • /auto/configure(获取configure的配置,生成Makefile)

  • objs/Makefile(由第一步生成)

  • make(*.o生成,连接成nginx)

针对http geo模块连接过程进行示范

1.configure

path:auto/configure

. auto/options
...

2.options 参数

  • path: auto/option

  • path: auto/modules

某个配置是否开启

 --without-stream_geo_module        disable ngx_stream_geo_module
  --with-debug                       enable debug logging

HTTP_GEO变量被设置为YES, geo模块开启.

    if [ $HTTP_GEO = YES ]; then
        have=NGX_HTTP_X_FORWARDED_FOR . auto/have

        ngx_module_name=ngx_http_geo_module
        ngx_module_incs=
        ngx_module_deps=
        ngx_module_srcs=src/http/modules/ngx_http_geo_module.c
        ngx_module_libs=
        ngx_module_link=$HTTP_GEO

        . auto/module
    fi

3.objs/ngx_modules.c

  • extern 声明目标模块(geo, 自定义模块)

  • ngx_modules: 注册模块

  • ngx_module_names: 定义模块名

4.objs/Makefile

  • 编译目标.o

  • 把目标.o连接到nginx

eg:ngx_http_geo_module.o模块的生成

objs/src/http/modules/ngx_http_geo_module.o:	$(CORE_DEPS) $(HTTP_DEPS) \
	src/http/modules/ngx_http_geo_module.c
	$(CC) -c $(CFLAGS) $(CORE_INCS) $(HTTP_INCS) \
		-o objs/src/http/modules/ngx_http_geo_module.o \
		src/http/modules/ngx_http_geo_module.c

5.验证nginx中已经连接了目标模块

  • ngx_http_geo_module

  • ngx_http_mytest_module(自定义模块)

➜  nginx git:(hyh_test) ✗ nm objs/nginx | grep geo_mod
00000001000a5420 D _ngx_http_geo_module
00000001000bdf68 b _ngx_http_geo_module_ctx
➜  nginx git:(hyh_test) ✗ 
➜  nginx git:(hyh_test) ✗ nm objs/nginx | grep mytest 
0000000100071860 t _ngx_http_mytest_block
00000001000a5500 d _ngx_http_mytest_commands
00000001000a5570 D _ngx_http_mytest_module
00000001000bdfb8 b _ngx_http_mytest_module_ctx
➜  nginx git:(hyh_test) ✗

关于“Nginx如何编译连接”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

本文标题:Nginx如何编译连接
当前地址:https://www.cdcxhl.com/article42/iieihc.html

成都网站建设公司_创新互联,为您提供商城网站网站维护做网站App开发域名注册外贸网站建设

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都定制网站网页设计