Cenos8 编译安装Nginx 1.17 +Nginx_rtmp_module

1、下载Nginx1.17

cd /usr/local/src/

wget http://nginx.org/download/nginx-1.17.10.tar.gz

解压缩nginx

tar -zvxf nginx-1.17.10.tar.gz

2、下载Nginx_rtmp_module模块

Nginx_rtmp_module模块github地址:https://github.com/arut/nginx-rtmp-module

git clone https://github.com/arut/nginx-rtmp-module.git

3、安装编译环境和依赖

dnf install -y gcc gcc-c++ openssl openssl-devel gcc* libxml2 libxml2-devel pcre pcre-devel libxslt libxslt-devel

4、编译安装nginx1.17

cd nginx-1.17.10

./configure --with-http_xslt_module --with-http_stub_status_module --with-http_gzip_static_module --add-module=/usr/local/src/nginx-rtmp-module

make

make过程中报错如下:

/usr/local/src/nginx-rtmp-module/ngx_rtmp_eval.c: 在函数‘ngx_rtmp_eval’中:
/usr/local/src/nginx-rtmp-module/ngx_rtmp_eval.c:160:17: 错误:this statement may fall through [-Werror=implicit-fallthrough=]
                 switch (c) {
                 ^~~~~~
/usr/local/src/nginx-rtmp-module/ngx_rtmp_eval.c:170:13: 附注:here
             case ESCAPE:
             ^~~~
cc1:所有的警告都被当作是错误
make[1]: *** [objs/Makefile:1368:objs/addon/nginx-rtmp-module/ngx_rtmp_eval.o] 错误 1
make[1]: 离开目录“/usr/local/src/nginx-1.17.10”

 

解决办法:

打开/usr/local/src/nginx-rtmp-module/ngx_rtmp_eval.c文件

vim /usr/local/src/nginx-rtmp-module/ngx_rtmp_eval.c

在第169行(空行)插入  /* fall through */ ,保存退出

再执行make一切正常

5、make install

6、将nginx服务加入到systemctl管理

vim /usr/lib/systemd/system/nginx.service 

输入如下内容

[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target

 

保存退出,就可以用systemctl start nginx了

7、加入自启动

systemctl enable nginx

 

声明:以上部分内容来自互联网

你可能感兴趣的:(Centos8)