yum安装下的nginx,如何添加模块,和添加第三方模块
需求:生产有个接口是通过socket通信。nginx1.9开始支持tcp层的转发,通过stream实现的,而socket也是基于tcp通信。
实现方法:Centos7.2下yum直接安装的nginx,添加新模块支持tcp转发;重新编译Nginx并添加 --with-stream 参数。
实现过程:
1. 查看nginx版本模块
[root@pre ~]# nginx -V
2. 下载一个同版本可编译的Nginx
cd /opt
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar xf nginx-1.12.2.tar.gz && cd nginx-1.12.
3. 备份原Nginx文件
mv /usr/sbin/nginx /usr/sbin/nginx.bak
cp -r /etc/nginx{,.bak}
4. 重新编译Nginx
检查模块是否支持,比如这次添加 limit 限流模块 和 stream 模块:
./configure –help | grep limit
这里写图片描述
ps:-without-http_limit_conn_module disable 表示已有该模块,编译时,不需要添加
./configure –help | grep stream
这里写图片描述
ps:–with-stream enable 表示不支持,编译时要自己添加该模块
根据第1步查到已有的模块,加上本次需新增的模块: --with-stream

cd /opt/nginx-1.12.2 ./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 --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_auth_request_module --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_geoip_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_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic' --with-ld-opt='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-E' --with-stream

以上编译时,如出现缺少依赖,一般需要安装以下模块,安装完再次编译:
yum -y install libxml2 libxml2-dev libxslt-devel
yum -y install gd-devel
yum -y install perl-devel perl-ExtUtils-Embed
yum -y install GeoIP GeoIP-devel GeoIP-data
yum -y install pcre-devel
yum -y install openssl openssl-devel
5. 编译通过,继续验证
继续输入:make
make完成后不要继续输入“make install”,以免现在的nginx出现问题
以上完成后,会在objs目录下生成一个nginx文件,先验证:
/opt/nginx-1.12.2/objs/nginx -t
/opt/nginx-1.12.2/objs/nginx -V
6. 替换Nginx文件并重启
cp /opt/nginx-1.12.2/objs/nginx /usr/sbin/
nginx -s reload
7. 检查
[root@pre ~]# nginx -V
添加模块成功!!!
yum安装下的nginx,如何添加模块,和添加第三方模块的更多相关文章
- Python学习手册之__main__ 模块,常用第三方模块和打包发布
在上一篇文章中,我们介绍了 Python 的 元组拆包.三元运算符和对 Python 的 else 语句进行了深入讲解,现在我们介绍 Python 的 __main__ 模块.常用第三方模块和打包发布 ...
- yum安装 lnmp (linux+nginx+php7.1+mysql5.7)
1.第一步先更新yum update 2.yum安装nginx安装nginx最新源:yum localinstall http://nginx.org/packages/centos/7/noarch ...
- centos6服务器YUM安装LNMP(LINUX+NGINX+MYSQL+PHP)
之前都用的lamp,这次配置一个lnmp来看看,试试Nginx是不是好用 关闭SELINUXvi /etc/selinux/config#SELINUX=enforcing #注释掉#SELINUXT ...
- centos yum安装redis,nginx
先安装源 yum install epel-release 之后 分别安装redis,nginx
- python_way ,day5 模块,模块3 ,双层装饰器,字符串格式化,生成器,递归,模块倒入,第三方模块倒入,序列化反序列化,日志处理
python_way.day5 1.模块3 time,datetime, json,pickle 2.双层装饰器 3.字符串格式化 4.生成器 5.递归 6.模块倒入 7.第三方模块倒入 8.序列化反 ...
- ubuntu 下编译安装 mysql php nginx 及常见错误 (持续添加)
mysql mysql 可以使用mysql 官方提供的apt源进行安装 参见这里 php 安装前先安装一些常见库 sudo apt-get install libpng16-16 libpng16-d ...
- centos7 yum 安装最新的nginx 1.16
参考:https://www.cnblogs.com/opsprobe/p/10773582.html nginx官方文档说明:http://nginx.org/en/linux_packages.h ...
- 解决centos yum安装"No package nginx available."问题
问题原因: nginx位于第三方的yum源里面,而不在centos官方yum源里面 解决方法: 安装epel(Extra Packages for Enterprise Linux) a.去epel网 ...
- yum 安装 PHP,apache,nginx,mysql
如果是Centos OS 64 位,首先更新 rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarc ...
随机推荐
- Fedora 23+CUDA 8.0+ GTX970 安装
https://www.if-not-true-then-false.com/2015/fedora-nvidia-guide/ PRE-INSTALLATION ACTIONS Some actio ...
- Linux 安装 ffmpeg
在安装ffmpeg之前,需要先安装一些必需组件.包括但不限于以下组件(有的系统里面可能已经安装过) 首先在根目录下创建:ffmpeg_sources 1.Yasm sudo apt-get insta ...
- Win10系列:C#应用控件进阶2
矩形 若要绘制矩形需要用到Rectangle元素,通过指定Rectangle元素的Width和Height属性值来确定矩形的尺寸.而设置RadiusX和RadiusY属性值能得到圆角的矩形,这两个属性 ...
- L337 Should We Relax About Screen Time?
The UK government's plans for regulation of the internet and social media contained a long list of o ...
- Element分页组件prev-text和next-text属性无效?
前情提要 /(ㄒoㄒ)/~~ 作为刚刚接触 Element 组件的人来说,看文档是第一步,但是当我想要修改分页组件里面的按钮时却遇到了问题. 文档中写到是需要给 prev-text 和 next-te ...
- 真机*Appium
一.真机连接电脑123 1.一般android手机的的USB调试模式在设置里的开发者选项中,找到开发者选项,打开USB调试 2.cmd命令→[adb devices]→回车,得到真机设备 可能存在问题 ...
- C# 时间控件 竖直进度条 饼图显示 仪表盘 按钮基础控件库
Prepare 本文将使用一个NuGet公开的组件来实现一些特殊的控件显示,方便大家进行快速的开发系统. 在Visual Studio 中的NuGet管理器中可以下载安装,也可以直接在NuGet控制台 ...
- 05_解决mac百度网盘下载速度慢问题
第一步:下载软件 下载工具包:aria2GUI和chrom插件 链接:https://pan.baidu.com/s/104t6aZXx9zfxBV9rS_eLfg 密码:yg96 ①下载Aria2 ...
- webpack配置(入口出口)
const path=require('path'); //是node.js的path模块 //单入口,单出口 module.exports={ // 入口文件 entry:{ entry:'./sr ...
- Mysql 杀死sleep进程
查询数据库当前设置的最大连接数:查看mysql数据库连接数.并发数相关信息 show global variables like '%max_connections%'; 查看mysql连接数:my ...