首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >专栏 >麒麟 欧拉系统 yum安装nginx添加编译模块

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

作者头像
Kevin song
发布于 2023-02-22 13:40:38
发布于 2023-02-22 13:40:38
2.2K00
代码可运行
举报
运行总次数:0
代码可运行

概述

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
代码运行次数:0
运行
AI代码解释
复制
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
代码运行次数:0
运行
AI代码解释
复制
wget http://nginx.org/download/nginx-1.16.1.tar.gz

解压源码包

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
tar -xzvf nginx-1.16.1.tar.gz

3,备份现有的nginx文件

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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
代码运行次数:0
运行
AI代码解释
复制
./nginx -V

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
cp objs/nginx /usr/sbin/
systemctl   restart  nginx

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

vim /etc/nginx/nginx.conf

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
location = /basic_status {
stub_status;
allow 127.0.0.1;
allow ::1;
deny all;
}

重载配置文件

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
 nginx -s reload

7,curl访问测试

curl -L 127.0.0.1/basic_status

openEuler nginx-module-vts 模块

1,下载

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
wget https://github.com/vozlt/nginx-module-vts/archive/refs/tags/v0.2.1.tar.gz

2,解压

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
tar -zvxf nginx-module-vts-0.2.1.tar.gz

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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
代码运行次数:0
运行
AI代码解释
复制
./nginx -V

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

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
cp objs/nginx /usr/sbin/
systemctl   restart  nginx

7,nginx 配置

vim /etc/nginx/nginx.conf

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
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
代码运行次数:0
运行
AI代码解释
复制
nginx -s reload

8,浏览器访问

http://192.168.43.165/status

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

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

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

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

评论
登录后参与评论
暂无评论
推荐阅读
编辑精选文章
换一批
nginx平滑添加stream模块
1、操作背景 操作系统版本:CentOS Linux release 7.4.1708 (Core) nginx版本:1.13.4 nginx从1.9.0版本开始,新增了ngx_stream_core_module模块,使nginx支持四层负载均衡。默认编译的时候该模块并未编译进去,需要编译的时候添加--with-stream,使其支持stream代理。 2、nginx编译添加stream模块 2.1、查看原nginx编译参数 [root@test-server sbin]# nginx -V nginx
随心助手
2019/10/15
11.2K0
如何在生产环境中不停机升级 nginx、或者不停机引入 nginx 第三方模块
在引入第三方模块pagespeed 的时候,查阅了官网发现,引入第三方需要重新安装升级,还有就是通过 yum install 加载进去。
sinsy
2020/11/18
1.5K0
如何在生产环境中不停机升级 nginx、或者不停机引入 nginx 第三方模块
Nginx 整合 FastDFS 实现文件服务器
本篇衔接《FastDFS 环境搭建》内容进行讲解,上篇文章我们实现了图片上传的功能,但是无法通过 http 进行访问,本篇将解决该问题。
IT技术小咖
2019/06/26
8890
Nginx 整合 FastDFS 实现文件服务器
nginx升级1.9,支持tcp代理的stream模块
回忆:坑的来源 外网服务器nginx一直用的好好的,主要用于http代理和反代理,忽然有一天,客户想要外网访问内网的kafka,这样就必须 要支持tcp转发了,好吧,开始操作
零式的天空
2022/03/25
1.6K0
Tengine 安装配置
“Tengine是由淘宝网发起的Web服务器项目。它在Nginx 的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网 ,天猫商城 等得到了很好的检验。它的最终目标是打造一个高效、稳定、安全、易用的Web平台。”
用户2458545
2022/09/07
6630
Tengine 安装配置
nginx动态添加模块
有时候我们在环境部署nginx时,由于环境初期较简单,随着后期业务发展,需要的功能越来越多时,可能我们最开始编译安装的nginx已经无法满足我们现在的需求了,比如说,我们想使用nginx的缓存功能,想使用nginx的连接限制模块等,这时我们就需要在不覆盖之前已经编译好的nginx来动态添加所需的模块了。
dogfei
2020/07/31
2.3K0
Nginx安装fair模块
官方github下载地址:https://github.com/gnosek/nginx-upstream-fair 我已经放到了百度网盘,可以直接下载
互联网-小阿宇
2022/11/21
5740
Nginx安装fair模块
每个Linux用户必须知道的10个最常用的Nginx命令
Nginx(发音为Engine x)是一个免费的,开源的,高性能,可扩展,可靠,功能齐全且流行的HTTP和反向代理服务器,邮件代理服务器和通用TCP/UDP代理服务器。
星哥玩云
2022/07/26
9870
每个Linux用户必须知道的10个最常用的Nginx命令
Nginx添加模块http_image_filter_module实现图片缩略图功能
比如我的是1.12.2 下载地址http://nginx.org/download/nginx-1.12.2.tar.gz
码客说
2020/06/15
4.7K0
buntu20.04编译安装nginx 1.21.6并开启fastopen
简介: ubuntu20.04编译安装nginx 1.21.6并开启fastopen
姚华
2022/06/29
5000
yum安装的nginx添加http3
安装编译环境 dnf install gcc gcc-c++ pcre-devel openssl-devel zlib-devel cmake make go 克隆nginx http3依赖库 $ git clone https://gitee.com/fenghuolingyun/boringssl.git 配置编译依赖 cd boringssl mkdir build cd build cmake -DCMAKE_BUILD_TYPE=Release .. 配置发布稳定版本 默认使用`cmake .
峨眉山市雅铭网络
2022/03/07
9290
nginx点播mp4模块
如何通过浏览器直接播放MP4呢?换句话说就是使nginx增加一个可以播放MP4的模块----模块ngx_http_mp4_module为H.264/AAC文件,主要是以 .mp4、.m4v、和.m4a为扩展名的文件,提供伪流媒体服务端支持。
summerking
2022/10/27
1.8K0
nginx点播mp4模块
Nginx 目录列表美化
本文链接:https://lisz.me/tech/webmaster/ngx-fancyindex.html
zhonger
2022/10/28
8720
编译安装Nginx + PHP + MySQL
编译安装 Nginx # 创建用户和组 groupadd nginx useradd -s /sbin/nologin nginx # 编译安装 ./configure --prefix=/usr/local/nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/ng
陳斯托洛夫斯記
2022/10/27
1.1K0
Centos7下Nginx编译安装与脚本安装的记录
yum install -y wget make cmake gcc gcc-c++ \
菲宇
2022/12/21
3820
Centos7下Nginx编译安装与脚本安装的记录
2015博客升级记(三):CentOS 7.1编译安装Nginx1.9.0
这是《2015年博客升级记》系列文章的第三篇,主要记录如何在CentOS 7.1中编译安装Nginx官方最新的1.9.0版本。由于像Nginx、Mysql和PHP7的的源码都是用C/C++写的,所以自己的CentOS 7.1服务器上必须要安装gcc和g++软件(CentOS 7系列会自带这两个编译软件)。
typecodes
2024/03/29
1240
2015博客升级记(三):CentOS 7.1编译安装Nginx1.9.0
统信服务器操作系统【Nginx 编译安装】
Nginx是一款轻量级的开源、高性能的Web 服务器和反向代理服务器及电子邮件(IMAP/POP3)服务器。Nginx支持该可用架构部署,支持在不间断服务的情况下对软件版本进行热更新,其占用内存少、并发能力强、能支持高达 5w 个并发连接数。
Kevin song
2024/05/11
1.1K0
统信服务器操作系统【Nginx 编译安装】
Nginx实用模块
Nginx 是一个很强大的高性能Web和反向代理应用。原先一直停留在apt install nginx 的阶段,直到开始深入了解其模块等,才发现:nginx厉害!!nginx除了基础功能以外还有很多有趣且实用的模块。因为nginx内置了许多变量(http://nginx.org/en/docs/varindex.html 部分是模块实现)、逻辑运算、指令,组合起来,就可以实现强大的功能。
yumusb
2020/04/22
9880
Linux安装Nginx1-基于yum安装
安装之前查看端口,默认nginx使用的80端口,如果80端口已经占用启动过程中可能会报错,针对端口占用情况,可以停止占用端口的服务或者nginx改用其他端口启动,停用和改端口方法不再本文介绍
凯哥Java
2022/12/16
3.2K0
Linux安装Nginx1-基于yum安装
nginx安装脚本
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 6
dogfei
2020/07/31
7080
相关推荐
nginx平滑添加stream模块
更多 >
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档