rtmp的服务器有很多,本篇博客介绍如何安装配置nginx-rtmp服务器。
系统ubuntu, deepin或者其它linux版本。
先安装以下依赖sudo apt-get install libssl-dev
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev
sudo apt-get install zlib1g-dev
sudo apt-get install git
sudo apt-get install wget
nginx官网 http://nginx.org
创建文件夹存放nginxmkdir rtmp
cd rtmp
wget http://nginx.org/download/nginx-1.13.3.tar.gz
去github下载nginx-rtmp模块git clone https://github.com/arut/nginx-rtmp-module.git
tar -zxvf nginx-1.13.3.tar.gz
cd nginx-1.13.3
./configure --add-module=../nginx-rtmp-module
make
make install
由于版本nginx版本不同,这里不一定能编译通过。
没报错的话,会有如下目录
cd /usr/local/nginx
cd sbin
启动nginx ./nginx启动niginx时也可能出现错误,如下:
asdf@ubuntu:/usr/local/nginx/sbin$ ./nginx nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied) 2021/07/07 07:39:22 [emerg] 23751#0: mkdir() "/usr/local/nginx/client_body_temp" failed (13: Permission denied)
此时需要修改权限
sudo chown root nginx sudo chmod u+s nginx
查看进程
ps -ef|grep nginx
ifconfig 查看ip,浏览器访问ip,看到下图, 说明nginx安装ok.
配置文件修改, cd到nginx的conf目录 vim nginx.conf 添加如下内容
pkill nginx
重启./nginx
推本地流测试ffmpeg -re -i 1.mp4 -f flv rtmp://192.168.126.132/live
VLC播放测试