思路:下载nginx对应版本的编译安装包,利用./configue进行重新编译,然后覆盖yum安装目录下的nginx nginx.pid nginx.conf
1.先下载nginx对应版本的编译安装包
1.先切到nginx目录中cd /usr/local/nginx
查看nginx版本, nginx -V
2.可以先备份一下这个目录下nginx 、 nginx.pid 、 nginx.conf 文件,利用cp命令如
cp nginx /root/workspace
3.下载对应nginx包
cd /usr/local/src
wget http://nginx.org/download/nginx-1.18.0.tar.gz
4.解压nginx
tar zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
5.利用./configure -help
查看支持哪些模块,我看了没有rtmp,因为nginx-http-flv-module含rmtp,所以下载这个模块即可。所以下载包来引入。阿里云git clone慢的话可以百度解决一下,禁用一个参数即可。
cd /usr/local/src
git clone https://github.com/winshining/nginx-http-flv-module.git
5.因为我通过histroy命令找到之前编译的./configure 后的模块参数,如果不记得话可以百度一下怎么新增模块(我试了还是覆盖了,没成功,所以重新编译)或者尽量把需要的模块都编译进行吧。我的参数中有些模块是之前安装时已经下载好的模块,所以可以直接引用,如果用下面参数提示找不到的话可以百度去下载相应模块。
cd /usr/local/src/nginx-1.18.0
为了方便看,我将命令换行了
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/local/nginx/nginx.pid
--with-http_gzip_static_module
--with-http_stub_status_module
--with-file-aio
--with-http_realip_module
--with-http_ssl_module
--with-pcre=/usr/local/src/pcre-8.44
--with-zlib=/usr/local/src/zlib-1.2.11
--with-openssl=/usr/local/src/openssl-1.1.1g
--with-http_mp4_module
--with-http_flv_module
--add-module=/usr/local/src/nginx-http-flv-module
不换行命令如下:
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_gzip_static_module --with-http_stub_status_module --with-file-aio --with-http_realip_module --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.44 --with-openssl=/usr/local/src/openssl-1.1.1g --with-http_mp4_module --with-http_flv_module --add-module=/usr/local/src/nginx-http-flv-module
make -j2
make install
6.到此回到目录cd /usr/local/nginx
通过./nginx -V
可以看到有rtmp模块了。
感觉yum安装有点不方便,以后还是尽量编译安装,哈哈。