前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >麒麟 欧拉系统 yum安装nginx添加编译模块

麒麟 欧拉系统 yum安装nginx添加编译模块

作者头像
Kevin song
发布2023-02-22 21:40:38
1.7K0
发布2023-02-22 21:40:38
举报

概述

Zabbix 监控nginx服务需要“http_stub_status_module”模块,但openEuler和麒麟V10系统 yum install nginx 缺失“--with-http_stub_status_module”模块,需要下载同版本nginx源码包编译后替换nginx执行文件。

Prometheus 监控nginx 支持使用“http_stub_status_module”模块和第三方VTS监控工具。Kylin 和 openEuler 如此相似;

Kylin http_stub_status_module 模块

查看 http_stub_status 模块的可用性

代码语言:javascript
复制
nginx -V 2>&1 | grep -o with-http_stub_status_module

1,查看Nginx版本

通过nginx -V 查看 yum install nginx 的版本为1.16.1

nginx -V

nginx version: nginx/1.16.1

built by gcc 7.3.0 (GCC)

built with OpenSSL 1.1.1f 31 Mar 2020

TLS SNI support enabled

configure arguments: --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-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/kylin/kylin-hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/kylin/kylin-hardened-ld -Wl,-E'

2,下载nginx-1.16.1源码包

下载nginx-1.16.1.tar.gz

代码语言:javascript
复制
wget http://nginx.org/download/nginx-1.16.1.tar.gz

解压源码包

代码语言:javascript
复制
tar -xzvf nginx-1.16.1.tar.gz

3,备份现有的nginx文件

代码语言:javascript
复制
cp -r /etc/nginx /etc/nginx_bak
cp /usr/sbin/nginx /usr/sbin/nginx_bak

4,安装依赖并编译

4.1,安装依赖

yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel gd gd-devel libxslt-devel libunwind-devel gperftools gperftools-devel -y

4.2,编译

cd nginx-1.16.1 && ./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-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_stub_status_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/kylin/kylin-hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/kylin/kylin-hardened-ld -Wl,-E'

4.3,编译执行 “make -j8”命令

禁止执行“make install”命令,避免原有nginx文件被覆盖

执行完成在objs目录下生成一个nginx执行文件

代码语言:javascript
复制
./nginx -V

5,nginx执行文件替换,并重启服务

代码语言:javascript
复制
cp objs/nginx /usr/sbin/
systemctl   restart  nginx

6,配置nginx文件,开启状态监控

vim /etc/nginx/nginx.conf

代码语言:javascript
复制
location = /basic_status {
stub_status;
allow 127.0.0.1;
allow ::1;
deny all;
}

重载配置文件

代码语言:javascript
复制
 nginx -s reload

7,curl访问测试

curl -L 127.0.0.1/basic_status

openEuler nginx-module-vts 模块

1,下载

代码语言:javascript
复制
wget https://github.com/vozlt/nginx-module-vts/archive/refs/tags/v0.2.1.tar.gz

2,解压

代码语言:javascript
复制
tar -zvxf nginx-module-vts-0.2.1.tar.gz

3,移动nginx-module-vts-0.2.1目录到nginx编译目录下

代码语言:javascript
复制
mv nginx-module-vts-0.2.1 nginx-1.21.5/

4,编译

cd nginx-1.20.1 && ./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-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_stub_status_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_perl_module=dynamic --with-http_auth_request_module --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-google_perftools_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/generic-hardened-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fPIC -D_FORTIFY_SOURCE=2 -O2 -Wtrampolines -fsigned-char' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/generic-hardened-ld -Wl,-E -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack' --add-module=nginx-module-vts-0.2.1

5,编译执行 “make -j8”命令

禁止执行“make install”命令,避免原有nginx文件被覆盖 执行完成在objs目录下生成一个nginx执行文件

代码语言:javascript
复制
./nginx -V

6,nginx执行文件替换,并重启服务

代码语言:javascript
复制
cp objs/nginx /usr/sbin/
systemctl   restart  nginx

7,nginx 配置

vim /etc/nginx/nginx.conf

代码语言:javascript
复制
http {
 
    vhost_traffic_status_zone;   vhost_traffic_status_filter_by_host on;



location /status {
            vhost_traffic_status_display;
            vhost_traffic_status_display_format html;
        }

重载nginx配置

代码语言:javascript
复制
nginx -s reload

8,浏览器访问

http://192.168.43.165/status

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2023-01-04,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 开源搬运工宋师傅 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档