参考博文:https://hywlovexyc.info/blog/archives/572/
下载模块
yum -y install git git clone https://github.com/arut/nginx-rtmp-module.git
nginx添加模块命令(添加了fastdfs与rtmp模块)
./configure --add-module=/usr/local/fastdfs-nginx-module-master/src --add-module=/root/2019-05-08整理/inst/lnmp1.5-full/src/nginx-1.14.1/module/nginx-rtmp-module --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_realip_module
编译nginx
make && make install
nginx配置文件
#推流
rtmp {
server{
listen 1935;#监听的端口
chunk_size 4000;
application hls{
live on;
hls on;
hls_path /usr/local/html/hls;#视频流存放地址
hls_fragment 5s;
hls_playlist_length 15s;
hls_continuous on;#连续模式。
hls_cleanup on;#对多余的切片进行删除
hls_nested on;#嵌套模式
}
}
}
#视频流端口
server {
listen 8083;
location / {
root /usr/local/html;
}
}
nginx常用命令(在nginx根目录sbin下使用)
nginx -s reopen #重启Nginx
nginx -s reload #重新加载Nginx配置文件,然后以优雅的方式重启Nginx
nginx -s stop #强制停止Nginx服务
nginx -s quit #优雅地停止Nginx服务(即处理完所有请求后再停止服务)
nginx -t #检测配置文件是否有语法错误,然后退出
nginx -?,-h #打开帮助信息
nginx -v #显示版本信息并退出
nginx -V #显示版本和配置选项信息,然后退出
nginx -t #检测配置文件是否有语法错误,然后退出
nginx -T #检测配置文件是否有语法错误,转储并退出
nginx -q #在检测配置文件期间屏蔽非错误信息
nginx -p prefix #设置前缀路径(默认是:/usr/share/nginx/)
nginx -c filename #设置配置文件(默认是:/etc/nginx/nginx.conf)
nginx -g directives #设置配置文件外的全局指令
killall nginx #杀死所有nginx进程
推流
pc客户端使用ops推流
设置如图
拉流
PC端使用VLC player
拉取地址如图