ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

CentOS7.6下安装nginx1.20.1及nginx动态模块使用

2021-08-11 14:33:07  阅读:667  来源: 互联网

标签:nginx1.20 http stream -- dynamic module nginx CentOS7.6


需求说明

  1. 在系统中安装nginx1.20.1
  2. 动态引入stream模块

配置步骤

下载编译源码包

  1. 下载源码包到指定的目录,本次目录是在/u01下
wget http://nginx.org/download/nginx-1.20.1.tar.gz
  1. 解压并编译源码

本次编译的时候指定使用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
  1. 进入目录,测试访问
cd /usr/local/nginx/sbin/
./nginx
curl localhost

编译stream模块

  1. 进入之前下载解压后的源码包内
cd /u01/nginx-1.20.1/
  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

  1. 编译指定模块
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream=dynamic

注意,此时只需要make即可,不要执行make install

make
  1. 复制编译后的模块文件

在编译后,在/u01/nginx-1.20.1/objs中会有编译好的 ngx_stream_module.so模块,此时只需要将模块复制到nginx的工作目录即可,如果在nginx目录中没有modules也可以自己建立一个

cp ngx_stream_module.so    nginx_worker_dir/modules/
  1. 修改nginx.conf配置文件,载入模块
load_module  modules/ngx_stream_module.so;

stream {
   ....
}

  1. 新加载配置

官方介绍

https://nginx.org/en/docs/configure.html
https://nginx.org/en/docs/stream/ngx_stream_core_module.html

标签:nginx1.20,http,stream,--,dynamic,module,nginx,CentOS7.6
来源: https://www.cnblogs.com/GYoungBean/p/15128007.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有