RHEL 6.4下Nginx 1.6.0 插件开发记录

RHEL 6.4下Nginx 1.6.0 插件开发记录

1. nginx的编译部署
# ./configure --with-poll_module --with-http_ssl_module --with-file-aio --with-ipv6
# make install
# cd /usr/local/nginx/sbin
# ./nginx

# ps -ef | grep nginx
root      7330    1  0 22:46 ?        00:00:00 nginx: master process ./nginx
nobody    7331  7330  0 22:46 ?        00:00:00 nginx: worker process

# ./nginx -h
nginx version: nginx/1.4.2
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h        : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -q            : suppress non-error messages during configuration testing
  -s signal    : send signal to a master process: stop, quit, reopen, reload
  -p prefix    : set prefix path (default: /usr/local/nginx/)
  -c filename  : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file

// 停止服务
# ./nginx -s stop

2. 插件开发

代码目录结构:
/projects
  -nginx-1.6.0
  -nginx-http-myplugin
    --config
    --ngx_http_myplugin_module.c
    --ngx_http_myplugin_module.c


nginx-1.6.0是nginx自身的源代码目录
nginx-http-myplugin是我们的插件代码目录
 
config文件的内容:
# -*- mode:sh; -*-
ngx_addon_name=ngx_http_myplugin_module
HTTP_MODULES="$HTTP_MODULES ngx_http_myplugin_module"
NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_myplugin_module.c"


在/projects/nginx-1.6.0目录下运行下面命令进行编译:
./configure --with-poll_module --with-http_ssl_module --with-file-aio --with-ipv6 --add-module=../nginx-http-filerepair --with-debug

Nginx 的详细介绍请点这里
Nginx 的下载地址请点这里

扫描二维码关注公众号,回复: 2070103 查看本文章

猜你喜欢

转载自www.linuxidc.com/Linux/2015-07/120462.htm