网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

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如何编译连接
URL地址:http://bjjierui.cn/article/iieihc.html

其他资讯