赞
踩
基于centos7.9系统部署的
首先,确保你的服务器上已经安装了Docker。你可以从Docker官方网站根据你的操作系统下载并安装Docker。
1、docker镜像用docker-hub官方的:https://github.com/ossrs/srs/releases?q=v4&expanded=true
或阿里的 https://cr.console.aliyun.com/repository/cn-hangzhou/ossrs/srs/images
安装并启动SRS的容器
docker run --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 \
registry.cn-hangzhou.aliyuncs.com/ossrs/srs:5 ./objs/srs -c conf/docker.conf
运行容器会直接停留在容器运行界面,通过Ctrl+P+Q可后台形式退出容器
这时候其实已经运行成功!可以通过以下命令查看SRS控制台
http://[IP]:8080
要想外网可以访问,需要打开1935、8080、1985 三个端口号(云服务安全组)
此时流服务器已经可以使用,如果需要自定义配置文件可继续按照下面步骤。
创建自己的配置文件 srs.my.conf
# SRS 参考配置 listen 1935; max_connections 1000; srs_log_tank file; srs_log_file ./objs/srs.log; daemon on; http_api { enabled on; listen 1985; } http_server { enabled on; listen 8080; dir ./objs/nginx/html; # 开启 https 支持,需要开放 8088端口 # https { # enabled on; # listen 8088; # key ./conf/xxxx.key; # cert ./conf/xxxx.crt; # } } vhost __defaultVhost__ { # http-flv设置 http_remux{ enabled on; mount [vhost]/[app]/[stream].flv; hstrs on; } # hls设置 hls { enabled on; hls_fragment 1; hls_window 2; hls_path ./objs/nginx/html; hls_m3u8_file [app]/[stream].m3u8; hls_ts_file [app]/[stream]-[seq].ts; } # dvr设置 dvr { enabled off; dvr_path ./objs/nginx/html/[app]/[stream]/[2006]/[01]/[02]/[timestamp].flv; dvr_plan segment; dvr_duration 30; dvr_wait_keyframe on; } # rtc 设置 rtc { enabled on; bframe discard; } # SRS支持refer防盗链:检查用户从哪个网站过来的。譬如不是从公司的页面过来的人都不让看。 refer { # whether enable the refer hotlink-denial. # default: off. enabled off; # the common refer for play and publish. # if the page url of client not in the refer, access denied. # if not specified this field, allow all. # default: not specified. all github.com github.io; # refer for publish clients specified. # the common refer is not overrided by this. # if not specified this field, allow all. # default: not specified. publish github.com github.io; # refer for play clients specified. # the common refer is not overrided by this. # if not specified this field, allow all. # default: not specified. play github.com github.io; } # http 回调 http_hooks { # 事件:发生该事件时,即回调指定的HTTP地址。 # HTTP地址:可以支持多个,以空格分隔,SRS会依次回调这些接口。 # 数据:SRS将数据POST到HTTP接口。 # 返回值:SRS要求HTTP服务器返回HTTP200并且response内容为整数错误码(0表示成功),其他错误码会断开客户端连接。 # whether the http hooks enable. # default off. enabled on; # 当客户端连接到指定的vhost和app时 on_connect http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; # 当客户端关闭连接,或者SRS主动关闭连接时 on_close http://127.0.0.1:8085/api/v1/clients http://localhost:8085/api/v1/clients; # 当客户端发布流时,譬如flash/FMLE方式推流到服务器 on_publish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; # 当客户端停止发布流时 on_unpublish http://127.0.0.1:8085/api/v1/streams http://localhost:8085/api/v1/streams; # 当客户端开始播放流时 on_play http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; # 当客户端停止播放时。备注:停止播放可能不会关闭连接,还能再继续播放。 on_stop http://127.0.0.1:8085/api/v1/sessions http://localhost:8085/api/v1/sessions; # 当DVR录制关闭一个flv文件时 on_dvr http://127.0.0.1:8085/api/v1/dvrs http://localhost:8085/api/v1/dvrs; # 当HLS生成一个ts文件时 on_hls http://127.0.0.1:8085/api/v1/hls http://localhost:8085/api/v1/hls; # when srs reap a ts file of hls, call this hook, on_hls_notify http://127.0.0.1:8085/api/v1/hls/[app]/[stream]/[ts_url][param]; } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。