nginx 添加C++模块

ps:端口改变文件 安装目录的  ...(安装目录).../conf/nginx.comf中

1: ./configure --prefix=/usr/local/notifyServer/  --add-module=/usr/local/src/nginx_notifyserver_module

#-prefix=/usr/local/notifyServer/ 表示安装路径

在 /usr/local/src/nginx_notifyserver_module 中会有对应config文件以及C文件。

如:

#config
ngx_addon_name=ngx_notifyserver_module

HTTP_MODULES="$HTTP_MODULES ngx_http_notifyserver_module"

NGX_ADDON_SRCS="$NGX_ADDON_SRCS $ngx_addon_dir/ngx_http_notifyserver_module.c"

CORE_LIBS="$CORE_LIBS -lnotifyserver"

#ngx_http_notifyserver_module.c

#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>

#include <iconv.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <string.h>

#include "idm_service.h"


#define OUT_BUFSIZE 20480
#define IN_BUFSIZE 2048
#define CHAR_BUFSIZE 128
#define ERR_BUFSIZE 4096
typedef unsigned char BYTE;

static char *ngx_http_notifyserver_set(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);

static ngx_int_t ngx_http_notifyserver_init_master(ngx_log_t *log);
static ngx_int_t ngx_http_notifyserver_init_module(ngx_cycle_t *cycle);
static ngx_int_t ngx_http_notifyserver_init_process(ngx_cycle_t *cycle);
static ngx_int_t ngx_http_notifyserver_init_thread(ngx_cycle_t *cycle);
static void ngx_http_notifyserver_exit_thread(ngx_cycle_t *cycle);
static void ngx_http_notifyserver_exit_process(ngx_cycle_t *cycle);
static void ngx_http_notifyserver_exit_master(ngx_cycle_t *cycle);


static ngx_int_t make_http_header(ngx_http_request_t *r);
static ngx_int_t make_http_get_body(ngx_http_request_t *r, char *out_buf);


2:在安装目录中的 ..(安装目录).../obj/Makfile中添加对应编译代码

如:

objs/addon/nginx_notifyserver_module/ngx_http_notifyserver_module.o \
        objs/ngx_modules.o
...
objs/addon/nginx_notifyserver_module/ngx_http_notifyserver_module.o \
...
-lpthread -lcrypt -lnotifyserver -lpcre -lcrypto -lcrypto -lz	# 添加.c文件依赖的库
...
objs/addon/nginx_notifyserver_module/ngx_http_notifyserver_module.o:    $(ADDON_DEPS) \
        /usr/local/src/nginx_notifyserver_module/ngx_http_notifyserver_module.c
        $(CC) -c $(CFLAGS)  $(ALL_INCS) \
                -o objs/addon/nginx_notifyserver_module/ngx_http_notifyserver_module.o \
                /usr/local/src/nginx_notifyserver_module/ngx_http_notifyserver_module.c
 
 

3:make 

make install(如果是已经安装的,则去掉make install)



总结:顺序上应该是先make,在./configure 



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值