nginx模块开发
来源:互联网 发布:南京网络推广jssdky 编辑:程序博客网 时间:2024/05/21 19:34
http://www.codinglabs.org/html/intro-of-nginx-module-development.html
http://www.nginx.com.cn/?cat=80
http://wiki.nginx.org/3rdPartyModules
PS http://0xc0dec.org/2010/11/23/nginx-directive-is-duplicate/
—————— 关于 设定配置文件为uint 的情况下,如果木有给定初始值NGX_CONF_UNSET_UINT,则会报错 描述符重复。
http://bollaxu.iteye.com/blog/855497
http://bollaxu.iteye.com/blog/900357
http://www.162cm.com/p/ngx_ext.html
打开调试,关闭daemon模式
~#vim nginx.confworker_processes 1;daemon off; master_process off;error_log /tmp/error.log debug;pid /tmp/nginx_demo.pid;events { worker_connections 1024;}http { include /etc/nginx/mime.types; sendfile on; keepalive_timeout 65; tcp_nodelay on; server { listen 8100; server_name localhost; access_log /tmp/access.log; error_log /tmp/error.log debug; location /hello { echo "Hi,this is a demo module"; } }}
http://www.evanmiller.org/nginx-modules-guide.html
http://www.evanmiller.org/nginx-modules-guide-advanced.html
http://www.pagefault.info/?p=251
http://lxr.evanmiller.org/http/source/core/ngx_core.h#L33
http://lxr.evanmiller.org/http/ident?i=NGX_OK
编译入C++模块包含其他lib的方案
http://blog.xiuwz.com/2011/11/27/nginx-build-with-cpp/
Nginx是基于C语言开发的,默认采用GCC编译。如果第三方模块需要采用C++来编写,需要如何做呢?网上不少教材采用修改Makefile或者在Confiugure中把GCC修改成G++,这种方案有一定的可行性,但很有可能导致一些其他的问题,比如说Nginx的off_t在32位系统的兼容性问题。另外这方法在nginx官方中也非常不推荐。
在Nginx代码中,本身有一段关于引入C++模块的实例代码 :/src/misc/ngx_cpp_test_module.cpp
extern "C" { #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> #include <ngx_event_connect.h> #include <ngx_event_pipe.h> #include <ngx_http.h> #include <ngx_mail.h> #include <ngx_mail_pop3_module.h> #include <ngx_mail_imap_module.h> #include <ngx_mail_smtp_module.h>}
测试编译方法:./configure –with-ld-opt=”-lstdc++” –with-cpp_test_module && make
如果该C++模块还依赖了其他的C++库和头部文件,又该如何做呢?在网上没有找到类似的方法后,只能去看看nginx的configure和makefile的实现了。PS:nginx的makefile生成采用了自己的方式来做,对于源码中的Auto目录。(后续详细介绍)
通过分析,整理出nginx引入C++模块的几个步骤:
1、nginx头文件需要放在extern “c”中。如同ngx_cpp_test_module.cpp文件一样。
2、在模块中config文件中定义额外的头文件目录、第三方库。注意:NGX_ADDON_DEPS、NGX_ADDON_SRCS、CORE_INCS、CORE_LIBS几个定义。
ULIB="/path/to/lib/lib2-64"CORE_INCS="$CORE_INCS $ULIB/ullib/include $ULIB/dict/include $ULIB/ccode/include $ULIB/cache/include $ULIB/xxx/output/include /usr/include/libxml2 /usr/include/pcre"CORE_LIBS="$CORE_LIBS -lcrypto -lm -L$ULIB/ullib/lib/ -L$ULIB/ccode/lib/ -L$ULIB/htmlparser2/lib/ -L$ULIB/dict/lib/ -L$ULIB/cache/lib/ -L$ULIB/xxx/output/lib -lpolicy -lpcre -lulccode -lhtmlparser2 -luldict -lmcache -lxml2 -lcrypt -lcrypto -lullib"
3、在configure中添加“–with-ld-opt=”-lstdc++” ”
完成这几个步骤就done了。
-------------------------------------------------------------
Nginx模块参考手册中文版
http://www.howtocn.org/nginx:nginx%E6%A8%A1%E5%9D%97%E5%8F%82%E8%80%83%E6%89%8B%E5%86%8C%E4%B8%AD%E6%96%87%E7%89%88
- Nginx基础知识. Nginx模块开发
- Nginx模块开发入门
- Nginx模块开发入门
- nginx模块开发
- nginx模块开发说明
- Nginx模块开发
- NGINX模块开发
- Nginx Http模块开发
- Nginx 模块开发
- Nginx模块开发入门
- Nginx模块开发入门
- nginx模块开发指南
- Nginx模块开发入门
- NGINX模块开发入门
- Nginx模块开发实战
- Nginx模块开发
- nginx模块开发入门
- 开发Nginx模块Helloworld
- Vim代码缩进设置
- 2012第15周移动游戏榜单变化
- Linux下访问内存物理地址
- cache algorithm
- JAVA NIO 简介
- nginx模块开发
- mysql数据库怎么更改数据存放路径
- cli/sti 用法
- 正则表达式(Regex) 第一天
- regexec
- ClamAV学习【8】——64位Windows7下编译运行实践
- Background Subtraction and Modeling 常见的目标检测中的背景建模方法漫谈
- mac的ftp工具-cyberduck
- 如果是你,你该如何避免此事的发生---管理的思考(素材)