您的位置:首页 > 运维架构 > Nginx

nginx 1.9.10&nginx-sticky-module-1.1编译出错处理

2016-01-28 00:00 751 查看
1,下载nginx-1.9.10.tar.gz

解压:
tar -xzvf nginx-sticky-module-1.1.tar.gz

进入nginx-1.9.10目录
编译时出现错误:
cc1: warnings being treated as errors
ngx_http_sticky_module.c: In function ‘ngx_http_get_sticky_peer’:
/ngx_http_sticky_module.c:333: 警告:赋值时将整数赋给指针,未作类型转换
ake[1]: *** [objs/addon/nginx-sticky-module-1.1/ngx_http_sticky_module.o] 错误 1


a,根据资料 把ngx_http_sticky_misc.c 的281行修改如下

digest->len = ngx_sock_ntop(in, digest->data, len, 1);

改后
digest->len = ngx_sock_ntop(in, sizeof(struct sockaddr_in), digest->data, len, 1);

b,对nginx-sticky-module-1.1/ngx_http_sticky_module.c文件也进行修改(主要是1.9.x版本会出现这问题)
修改两个地方,如下图:
第6行添加:
#include <nginx.h>



第340行左右修改(iphp->rrp.current = iphp->selected_peer;)为:
#if defined(nginx_version) && nginx_version >= 1009000
iphp->rrp.current = peer;
#else
iphp->rrp.current = iphp->selected_peer;
#endif



330         /* we have a valid peer, tell the upstream module to use it */
331         if (peer && selected_peer >= 0) {
332                 ngx_log_debug(NGX_LOG_DEBUG_HTTP, pc->log, 0, "[sticky/get_sticky_peer] peer found at index %i", selected_peer);
333 #if defined(nginx_version) && nginx_version >= 1009000
334                 iphp->rrp.current = peer;
335 #else
336                 iphp->rrp.current = iphp->selected_peer;
337 #endif

从新进行编译;

./configure --prefix=/usr/local/nginx-1.9.10 --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module --add-module=../nginx-sticky-module-1.1
make
make install
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  nginx