首页 > 代码库 > NGINX编译安装后添加新模块的方法
NGINX编译安装后添加新模块的方法
刚忙完研发又有新的需求过来,测试服务器的nginx需要有HttpUpstreamRequestHashModule和HttpStubStatusModule;擦!安装软件环境时怎么不说清楚;妹的,悲剧。
测试服务器崩溃的是不是我安装的软件,天啊。赶紧搞吧!!!
环境:centos 6.4 64位 编译安装nginx
1:查看nginx版本和安装时间带的具体参数
/usr/local/nginx/sbin/nginx -V
2:下载相应的版本的nginx源码包[nginx-1.5.11.tar.gz],一起还要下载的有[Nginx_upstream_hash-0.3.1.tar.gz]
wget http://nginx.org/download/nginx-1.5.11.tar.gz
3:解压软件包到/opt下
4:重新配置
./configure --prefix=/usr/local/nginx-1.5.11 --user=www --group=www --with-http_stub_status_module --add-module=../nginx_upstream_hash-0.3.1/
报错./configure: error: invalid option "-user=www" 是由于-user=www少了一个"-"
应该写成"--user=www"
5:编译
make 然后 :make install
在make时有可能会报错:
../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c: In function ‘ngx_http_upstream_init_hash_peer’: ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c:155: error: ‘ngx_http_upstream_srv_conf_t’ has no member named ‘lengths’ ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c:155: error: ‘ngx_http_upstream_srv_conf_t’ has no member named ‘values’ ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c:173: error: ‘ngx_http_upstream_srv_conf_t’ has no member named ‘retries’ ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c: In function ‘ngx_http_upstream_hash’: ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c:291: error: ‘ngx_http_upstream_srv_conf_t’ has no member named ‘values’ ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c:292: error: ‘ngx_http_upstream_srv_conf_t’ has no member named ‘lengths’ ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c: In function ‘ngx_http_upstream_hash_again’: ../nginx_upstream_hash-0.3.1//ngx_http_upstream_hash_module.c:315: error: ‘ngx_http_upstream_srv_conf_t’ has no member named ‘retries’ make[1]: *** [objs/addon/nginx_upstream_hash-0.3.1/ngx_http_upstream_hash_module.o] Error 1 make[1]: Leaving directory `/opt/nginx-1.5.11‘ make: *** [build] Error 2
解决方法:在/opt/nginx-1.5.11/src/http/下的ngx_http_upstream.h中添加
ngx_array_t *values; ngx_array_t *lengths; ngx_uint_t retries; 位置是: struct ngx_http_upstream_srv_conf_s { ngx_http_upstream_peer_t peer; void **srv_conf; ngx_array_t *servers; /* ngx_http_upstream_server_t */ ngx_array_t *values; ngx_array_t *lengths; ngx_uint_t retries; ngx_uint_t flags; ngx_str_t host; u_char *file_name; ngx_uint_t line; in_port_t port; in_port_t default_port; ngx_uint_t no_port; /* unsigned no_port:1 */ };
然后再次执行 make; 问题得到解决。
本文出自 “在路上” 博客,请务必保留此出处http://jweiang.blog.51cto.com/8059417/1433675
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。