Mac搭建nginx+rtmp服務器

Mac搭建nginx+rtmp服務器

記錄下安裝rtmp的過程

一、安裝Homebrew

確認已經(jīng)安裝了Homebrew,可以通過brew -v查看版本的方式查看是否已經(jīng)安裝過,這個不用過多解釋。

 ~ brew -v
Homebrew 2.1.15
Homebrew/homebrew-core (git revision fcd3; last commit 2019-10-31)

如果沒有安裝,可以通過下面命令安裝:

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

自然卸載命令:

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

如果無法安裝,也可以嘗試下下面的方法:

/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"

二、安裝nginx

安裝過程我也是網(wǎng)上查來的,如果可以正常的安裝,我也就不寫這篇筆記了,首先安裝您可能搜到的步驟進行安裝:

brew tap homebrew/nginx

結果我遇到了下面的報錯:

Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
abyss               docker2aci          libhttpseverywhere  subversion
amqp-cpp            emscripten          mypy                tup
chronograf          grpc                packmol             znapzend
dnscrypt-proxy      influxdb            rancher-cli
Error: homebrew/nginx was deprecated. This tap is now empty as all its formulae were migrated.

最終在這篇博客找到了原因,根查原因是因為homebrew/nginx的git路徑變了。因此需要使用denji/nginx命令來解決這個問題。

通過下面的命令再試試:

~ brew tap denji/nginx

Updating Homebrew...

==> Tapping denji/nginx

Cloning into '/usr/local/Homebrew/Library/Taps/denji/homebrew-nginx'...

remote: Counting objects: 72, done.

remote: Compressing objects: 100% (72/72), done.

remote: Total 72 (delta 1), reused 28 (delta 0), pack-reused 0

Unpacking objects: 100% (72/72), done.

Tapped 62 formulae (162 files, 130.2KB)

到此,繼續(xù)執(zhí)行下面的命令:

~ brew install nginx-full --with-rtmp-module

==> Installing nginx-full from denji/nginx
Error: Cannot install denji/nginx/nginx-full because conflicting formulae are installed.
 nginx: because nginx-full symlink with the name for compatibility with nginx
Please `brew unlink nginx` before continuing.
Unlinking removes a formula's symlinks from /usr/local. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side-effects in the
resulting software.

還是會報錯,仔細看錯誤提示需要“brew unlink nginx”。那么我們先執(zhí)行再說:

~ brew unlink nginx

接下來配置config,在 /usr/local/etc/nginx 下的nginx.conf

rtmp {
    server {
        listen 1935;
        ping 30s;
        notify_method get;

        application myapp {
            live on;
            record off;
        max_connections 1024;
        }

    #增加對HLS支持開始
    application hls {
        live on;
        hls on;
        hls_path /usr/local/var/www/hls;
        hls_fragment 5s;
    }
    #增加對HLS支持結束
    }
}

三、啟動nginx

到此結束,我們啟動下nginx:

~ nginx

或者是重啟:

~ nginx -s reload

瀏覽器訪問下:http://localhost:8080,看結果是否如下圖呢:

image.png

那么 安裝過程到此完成了。

如果遇到端口被占用的問題,可以自己搜索下解決,目前安裝過程就到此為止了。

最后編輯于
?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 簡介 nginx是非常優(yōu)秀的開源服務器,用它來做hls或者rtmp流媒體服務器是非常不錯的選擇,本人在網(wǎng)上整理了安...
    這個年紀的情愫丶閱讀 813評論 2 2
  • 簡介 nginx是非常優(yōu)秀的開源服務器,用它來做hls或者rtmp流媒體服務器是非常不錯的選擇,本人在網(wǎng)上整理了安...
    九洲仙人閱讀 478評論 0 0
  • Mac搭建nginx+rtmp服務器 最近在學習直播,找了大部分資料學習,學到推流就嘗試搭建一個自己的rtmp推流...
    小餅干是只松鼠閱讀 851評論 11 4
  • 公司項目是直播相關,自己網(wǎng)上搜了搜MAC搭建rtmp服務器,總結一下。 1.打開終端,查看是否已經(jīng)按照了Homeb...
    碼代碼的小馬閱讀 502評論 0 0
  • 【幸福女孩 唐墨軒 一年級 鄭州 堅持原創(chuàng)分享第7天 2017.9.9 星期六】 七年前的昨天,我來到了這...
    何亞珂閱讀 707評論 0 5

友情鏈接更多精彩內(nèi)容