CentOS7.6下安装nginx1.20.1及nginx动态模块使用
2021/8/12 7:36:36
本文主要是介绍CentOS7.6下安装nginx1.20.1及nginx动态模块使用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
需求说明
- 在系统中安装nginx1.20.1
- 动态引入stream模块
配置步骤
下载编译源码包
- 下载源码包到指定的目录,本次目录是在/u01下
wget http://nginx.org/download/nginx-1.20.1.tar.gz
- 解压并编译源码
本次编译的时候指定使用http_stub_status_module和http_ssl_module
tar -zxvf nginx-1.20.1.tar.gz cd nginx-1.20.1/
配置编译使用的模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
编译
make
make install
- 进入目录,测试访问
cd /usr/local/nginx/sbin/ ./nginx curl localhost
编译stream模块
- 进入之前下载解压后的源码包内
cd /u01/nginx-1.20.1/
- 查看nginx支持的动态模块
[root@load-eco nginx-1.20.1]# ./configure --help | grep dynamic --with-http_xslt_module=dynamic enable dynamic ngx_http_xslt_module --with-http_image_filter_module=dynamic enable dynamic ngx_http_image_filter_module --with-http_geoip_module=dynamic enable dynamic ngx_http_geoip_module --with-http_perl_module=dynamic enable dynamic ngx_http_perl_module --with-mail=dynamic enable dynamic POP3/IMAP4/SMTP proxy module --with-stream=dynamic enable dynamic TCP/UDP proxy module --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module --add-dynamic-module=PATH enable dynamic external module --with-compat dynamic modules compatibility
- 编译指定模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream=dynamic
注意,此时只需要make即可,不要执行make install
make
- 复制编译后的模块文件
在编译后,在/u01/nginx-1.20.1/objs中会有编译好的 ngx_stream_module.so模块,此时只需要将模块复制到nginx的工作目录即可,如果在nginx目录中没有modules也可以自己建立一个
cp ngx_stream_module.so nginx_worker_dir/modules/
- 修改nginx.conf配置文件,载入模块
load_module modules/ngx_stream_module.so; stream { .... }
- 新加载配置
官方介绍
https://nginx.org/en/docs/configure.html
https://nginx.org/en/docs/stream/ngx_stream_core_module.html
这篇关于CentOS7.6下安装nginx1.20.1及nginx动态模块使用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29fail2ban nginx
- 2024-03-18install nginx proxy manager
- 2024-01-2444从零开始用Rust编写nginx,命令行参数的设计与解析及说明
- 2024-01-22比Nginx更好用的Gateway!
- 2024-01-17nginx daemon off
- 2023-12-30Nginx Vhost Traffic Status 是什么意思-icode9专业技术文章分享
- 2023-12-26使用nginx搭建creates.io镜像(稀疏索引)
- 2023-11-18centos7编译安装Nginx教程。
- 2023-11-02nginx启动命令和停止命令
- 2023-10-25Centos7系统Nginx负载均衡如何安装和配置?