Debian 系统搭建 rtmp 直播服务
1、安装编译环境和相应的库文件
apt-get install build-essential
apt-get install libpcre3 libpcre3-dev libssl-dev
2、下载并解压 nginx 和 rtmp 模块源代码
wget http://nginx.org/download/nginx-1.13.1.tar.gz
wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
tar zxvf nginx-1.13.1.tar.gz
unzip master.zip
3、重新编译 nginx 加载 rtmp 模块
cd nginx-1.13.1
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-cc-opt='-g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-z,relro -Wl,--as-needed' --with-ipv6 --add-module=/root/nginx-rtmp-module-master
make
make install
4、配置 nginx 的 rtmp 参数并重启
修改 nginx 配置文件
vim /etc/nginx/nginx.conf
添加如下节点
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
record off;
allow publish all;
allow play all;
}
}
}
重启 nginx
/etc/init.d/nginx restart
5、安装 ffmpeg 便于转码
sh -c 'echo "deb http://www.deb-multimedia.org jessie main" >> /etc/apt/sources.list'
apt-get update
apt-get install deb-multimedia-keyring
apt-get install ffmpeg
6、至此,服务器部分就搭建完毕,可以接收 rtmp 协议的推送和播放了,在 Mac 系统下 ,obs 可以作为推送端,vlc 可以作为播放器,如果想网页直接观看,则可以使用 jwplayer 作为前端。 具体步骤这里不在赘述!