<<返回

CentOS 7里如何编译安装Nginx-RTMP直播插件?

安装依赖包

下载最新版nginx源码

下载Nginx-RTMP插件源码

解压缩源码

配置Nginx

编译安装Nginx

启动nginx

CentOS 7里如何编译安装Nginx-RTMP直播插件?

安装依赖包

yum -y install gcc gcc-c++ pcre pcre-devel openssl openssl-devel zlib zlib-devel unzip

下载最新版nginx源码

mkdir downloads/
cd downloads/
wget http://nginx.org/download/nginx-1.9.9.tar.gz

下载Nginx-RTMP插件源码

wget https://github.com/arut/nginx-rtmp-module/archive/master.zip -O rtmp.zip

解压缩源码

unzip rtmp.zip
tar -zxvf nginx-1.9.9.tar.gz

配置Nginx

cd nginx-1.9.9/
./configure --add-module=../nginx-rtmp-module-master/ --with-http_realip_module

编译安装Nginx

make && make install

确认安装成功:

/usr/local/nginx/sbin/nginx -v

启动nginx

/usr/local/nginx/sbin/nginx

如果需要用systemctl来启动nginx, 请修改nginx的服务配置文件:

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

保存后reload配置:

systemctl daemon-reload

再尝试用systemctl启动nginx服务:

systemctl stop nginx
systemctl start nginx

参考:

https://www.vultr.com/docs/setup-nginx-rtmp-on-centos-7