搭建RTMP服務器

半年前記錄的了, 但是一直忙于工作, 沒有時間整理...

1.安裝Homebrew(如果還沒安裝的話)

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

2.安裝Nginx

brew tap homebrew/nginx
brew install nginx-full --with-rtmp-module

啟動nginx

nginx

測試(不出意外的話, 會看到Welcome to nginx!)

localhost:8080

3.配置RTMP
打開配置文件(mac 10.11 默認的地址)

vi /usr/local/etc/nginx/nginx.conf

在配置文件最后面(或者最前面, 不要嵌套在 http{ } 中間)添加RTMP配置.(修改配置后, 重新加載/啟動Nginx)

rtmp {
    server {
        listen 1935;
        application rtmplive {
            live on;
            record off;
        }
    }
}

關于RTMP配置信息, 看這里RTMP配置
配置完成之后需要重新啟動Nginx服務器
推流地址: rtmp://192.168.0.101:1935/rtmplive
推流要加上密鑰(房間號), 完整路徑如:rtmp://192.168.0.101:1935/rtmplive/room

至此完畢!


其他

nginx -s reload //重新加載
nginx -s reopen //重新打開
nginx -s stop   //停止
nginx -s quit   //退出

//Nginx安裝路徑
/usr/local/Cellar/nginx-full/   

//Nginx配置文件路徑
/usr/local/etc/nginx/nginx.conf     

//Nginx服務器根目錄
/usr/local/var/www  

//卸載Homebrew(如果需要卸載的話)
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

//Nginx
https://github.com/Homebrew/homebrew-nginx
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容