Ubuntu 16.04简易安装Nginx-rtmp-module
libnginx-mod-rtmp
是18.04上自带的,可以通过apt-get install libnginx-mod-rtmp
进行安装,在16.04
上如果想要安装,直接下载libnginx-mod-rtmp_1.14.0-0+xenial1_amd64.deb
安装的话会被告知nginx
版本过低,依赖有问题,需要16.04
自带的nginx
版本是1.10
,rtmp需要1.14
。而一些其他文章都是需要编译nginx
和nginx-rtmp-module
来实现的安装。而我并不想上来就编译。找到了升级nginx
的方法,将nginx
升级后即可apt-get install libnginx-mod-rtmp
安装libnginx-mod-rtmp
了。
升级nginx到1.14
依次运行如下命令:
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
来源:https://stackoverflow.com/a/44116781/2193455
安装libnginx-mod-rtmp
tony@pc:~/Downloads$ sudo apt-get install libnginx-mod-rtmp
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
binutils-arm-linux-gnueabihf cpp-5-arm-linux-gnueabihf cpp-arm-linux-gnueabihf gcc-5-arm-linux-gnueabihf-base gcc-5-cross-base libasan2-armhf-cross libatomic1-armhf-cross libc6-armhf-cross libc6-dev-armhf-cross
libgcc-5-dev-armhf-cross libgcc1-armhf-cross libgomp1-armhf-cross libstdc++6-armhf-cross libubsan0-armhf-cross linux-headers-4.15.0-33 linux-headers-4.15.0-33-generic linux-image-4.15.0-33-generic linux-libc-dev-armhf-cross
linux-modules-4.15.0-33-generic linux-modules-extra-4.15.0-33-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
libnginx-mod-rtmp
0 upgraded, 1 newly installed, 0 to remove and 14 not upgraded.
Need to get 142 kB of archives.
After this operation, 371 kB of additional disk space will be used.
Get:1 http://ppa.launchpad.net/nginx/stable/ubuntu xenial/main amd64 libnginx-mod-rtmp amd64 1.14.0-0+xenial1 [142 kB]
Fetched 142 kB in 23s (6,165 B/s)
Selecting previously unselected package libnginx-mod-rtmp.
(Reading database ... 363674 files and directories currently installed.)
Preparing to unpack .../libnginx-mod-rtmp_1.14.0-0+xenial1_amd64.deb ...
Unpacking libnginx-mod-rtmp (1.14.0-0+xenial1) ...
Setting up libnginx-mod-rtmp (1.14.0-0+xenial1) ...
Processing triggers for nginx-full (1.14.0-0+xenial1) ...
Triggering nginx reload ...
tony@pc:~/Downloads$
这样就成功在Ubuntu 16.04上安装了libnginx-mod-rtmp
。
测试
打开/etc/nginx/nginx.conf
添加如下配置
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
}
}
}
然后先重启
sudo systemctl restart nginx
开启推流端
ffmpeg -i test.mp4 -codec copy -f flv rtmp://localhost/live
开启拉流端
ffplay "rtmp://localhost/live live=1"
其他注意事项
如果是在阿里云或者腾讯云上安装,还要在安全组里打开1935
端口。

网友评论