ubuntu16.04 一键安装nginx-rtmp

给nginx加rtmp协议,网上写的都是重新编译安装,这样会比较麻烦,编译的时候会报很多依赖缺失的问题,这个其实是可以通过apt-get一键安装

参考:https://blog.csdn.net/kangear/article/details/83019640

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

然后安装rtmp

sudo apt-get install libnginx-mod-rtmp

 centos7.x系列在编译安装过程中可能有n多个报错。。按照网上的方法。忽略报错即可,最后可能就是没法用systemctl命令去启动服务,这时只需要自己手动添加就好:

vim /usr/lib/systemd/system/nginx.service  # 内容一般都是默认的

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

此时就可以使用:systemctl status/stop/start/restart nginx等命令进行相关操作

原文地址:https://www.cnblogs.com/52-qq/p/11812815.html