1、下载源码
git clone -b 4.0release https://gitee.com/ossrs/srs.git
2、编译

注意需要切换到srs/trunk目录

cd srs/trunk
./configure
make
3、修改端口号
3.1 修改配置文件
vim /usr/local/server/srs/trunk/conf/srs.conf

修改http_server配置项的listen端口号为:9090

# main config for srs.
# @see full.conf for detail config.

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          9090;
    dir             ./objs/nginx/html;
}
rtc_server {
    enabled on;
    listen 8000; # UDP port
    # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#config-candidate
    candidate $CANDIDATE;
}
vhost __defaultVhost__ {
    hls {
        enabled         on;
    }
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }
    rtc {
        enabled     on;
        # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtmp-to-rtc
        rtmp_to_rtc off;
        # @see https://github.com/ossrs/srs/wiki/v4_CN_WebRTC#rtc-to-rtmp
        rtc_to_rtmp off;
    }
}

3.2 修改页面端口号

修改http的端口号为9090

vim /usr/local/server/srs/trunk/objs/nginx/html/console/js/srs.console.js
 ############################################################################################## 
 614 // the sc server is the server we connected to.
 615 scApp.provider("$sc_server", [function(){
 616     this.$get = function(){
 617         var self = {
 618             schema: "http",
 619             host: null,
 620             port: 1985,
 621             rtmp: [1935],
 622             http: [8081],
 623             baseurl: function(){
 624                 return self.schema + "://" + self.host + (self.port === 80? "": ":" + self.port);
 625             },
 626             jsonp: function(url){
3.3 修改主页跳转js
 vim /usr/local/server/srs/trunk/objs/nginx/html/index.html
###################
# 将 parseInt(window.location.port) 
###################
 50         // Build console url.
 51         if (true) {
 52             // The prefix for default website.
 53             const prefix = `${window.location.protocol}//${window.location.host}`;
 54             // If not 8080, user should proxy to the default port.
 55             const query = parseInt(window.location.port) === 8081 ? `?port=1985` : '';
 56             const enUrl = `${prefix}/console/en_index.html#/summaries${query}`;
 57             const cnUrl = `${prefix}/console/ng_index.html#/summaries${query}`;
 58             document.getElementById("enConsole").setAttribute('href', enUrl);
 59             document.getElementById("cnConsole").setAttribute('href', cnUrl);
 60         }
 61 
 62         // The player url.
 63         if (true) {
 64             const prefix = `players/?schema=${window.location.protocol.replace(':', '')}`;
 65             const httpPort = window.location.port || (window.location.protocol === 'http:' ? 80 : 443);
 66             // If not 8080, user should proxy both stream and API to the default port.
 67             const query = parseInt(window.location.port) === 8081 ? '' : `&port=${httpPort}&api=${httpPort}`;
 68             document.getElementById("enPlayer").setAttribute('href', `${prefix}${query}`);
 69             document.getElementById("cnPlayer").setAttribute('href', `${prefix}${query}`);
 70        }

4、启动服务器:
nohup ./objs/srs -c conf/srs.conf >/dev/null 2> &1 &
5、检查SRS启动情况
http://localhost:9090/ ,或者执行命令
# 查看SRS的状态
./etc/init.d/srs status
MB0:trunk $ ./etc/init.d/srs status
SRS(pid 90408) is running.                                 [  OK  ]
#如果异常   查看日志排查

# 或者看SRS的日志
tail -n 30 -f ./objs/srs.log
开启webrtc
文档更新时间: 2023-12-18 03:25   作者:JeffreyCheung