门户网站开发视频教学,找建设网站公司哪家好,做企业网站要多长时间,全国企业网查询本篇文章对于在服务器已经安装了nginx,但却希望使用Tengine 的状态检查或其他功能时使用#xff0c;不需要卸载服务器上的nginx,思路是使用干净服务器#xff08;未安装过nginx#xff09;通过编译安装Tengine#xff0c;通过对./configure的配置#xff0c;保证安装Tengi…本篇文章对于在服务器已经安装了nginx,但却希望使用Tengine 的状态检查或其他功能时使用不需要卸载服务器上的nginx,思路是使用干净服务器未安装过nginx通过编译安装Tengine通过对./configure的配置保证安装Tengine的环境与nginx服务器相同同时加入需要的Tengine模块编译最后将nginx代码传送至nginx服务器对应位置覆盖原先nginx代码完成nginx服务器上Tengine功能的更新。
1.前往Changelog - The Tengine Web Server下载最新的tengine的tar包
2.解压tar包并进入目录中
3.编译安装前安装依赖
yum install -y gcc make pcre pcre-devel openssl openssl-devel zlib zlib-devel geoip geoip-devel perl perl-devel gperftools gperftools-devel libxslt libxslt-devel
yum install -y gd-devel
yum -y install perl-ExtUtils-Embed
此处例举大部分依赖若下面出现问题大概率是此处缺少其他依赖
4.在已经配置好nginx的机器上使用nginx -V,查看nginx的configure argument
--prefix/usr/share/nginx --sbin-path/usr/sbin/nginx --modules-path/usr/lib64/nginx/modules --conf-path/etc/nginx/nginx.conf --error-log-path/var/log/nginx/error.log --http-log-path/var/log/nginx/access.log --http-client-body-temp-path/var/lib/nginx/tmp/client_body --http-proxy-temp-path/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path/var/lib/nginx/tmp/scgi --pid-path/run/nginx.pid --lock-path/run/lock/subsys/nginx --usernginx --groupnginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_moduledynamic --with-http_mp4_module --with-http_perl_moduledynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_moduledynamic --with-maildynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-streamdynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE2 -fexceptions -fstack-protector-strong --paramssp-buffer-size4 -grecord-gcc-switches -specs/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtunegeneric --with-ld-opt-Wl,-z,relro -specs/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E 5.配置环境在目录中运行如下命令./configure 上面复制的配置信息需要添加的模块
注意此处需要在tengine目录下因为下面使用的是相对地址
因为tengine服务把ngx常用的第3方模块放在了源代码中的modules目录下面。
--add-modulemodules/ngx_http_upstream_check_module 编译安装的时候增加upstream_check模块
--add-modulemodules/ngx_http_upstream_session_sticky_module/ 增加会话共享模块
./configure --prefix/usr/share/nginx --sbin-path/usr/sbin/nginx --modules-path/usr/lib64/nginx/modules --conf-path/etc/nginx/nginx.conf --error-log-path/var/log/nginx/error.log --http-log-path/var/log/nginx/access.log --http-client-body-temp-path/var/lib/nginx/tmp/client_body --http-proxy-temp-path/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path/var/lib/nginx/tmp/scgi --pid-path/run/nginx.pid --lock-path/run/lock/subsys/nginx --usernginx --groupnginx --with-compat --with-debug --with-file-aio --with-google_perftools_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_degradation_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_moduledynamic --with-http_mp4_module --with-http_perl_moduledynamic --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_xslt_moduledynamic --with-maildynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-streamdynamic --with-stream_ssl_module --with-stream_ssl_preread_module --with-threads --with-cc-opt-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE2 -fexceptions -fstack-protector-strong --paramssp-buffer-size4 -grecord-gcc-switches -specs/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtunegeneric --with-ld-opt-Wl,-z,relro -specs/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E --add-modulemodules/ngx_http_upstream_check_module/ --add-modulemodules/ngx_http_upstream_session_sticky_module/
6.进行编译
make -j 1 这里1为cpu核心或者直接make也可以
正常这一步如果要安装Tenginemake install 即可这里不需要安装。
7.将当前目录下的objs下的nginx代码传到负载均衡服务器
scp ./objs/nginx lb01:~
8.负载均衡服务器检查./nginx -V检查scp过来的nginx信息 注意图片最后两行已经加了对应的模块
9.将nginx代码替换掉原来的scp是传至家目录所以下面两条命令执行也是在家目录下。
mv /sbin/nginx /sbin/nginx1
mv nginx /sbin/nginx
10.nginx -V检查nginx信息此时已经可以看到信息如第8步一致
注意第八步看的是家目录下的nginx代码信息此处看的是服务器nginx代码信息
nginx -t检查语法
kill -USR2 pid (通过老的命令向当前运行的ngx发送信号准备被新的ngx进程替代)
kill pid(之前的ngx服务)
systemctl restart nginx 重新启动nginx。
11.对需要状态检查的页面进行配置可以参考Tengine官网ngx_http_upstream_check_module - The Tengine Web Server 配置完成即可查看各个web服务器信息 12.各个参数
check interval3000 rise2 fall5 timeout1000 typehttp;
检查间隔3000ms,成功两次即为活跃状态失败五次即为挂掉状态检查类型为http请求
check_http_send 代理向web服务器通过http方式发出请求报文,请求报文起始行,请求方法, 请求的URI,请求协议(默认使用的是ip方式 访问
check_http_expect_alive 收到指定的状态码,就认为是存活的