Mac搭建nginx+rtmp服務(wù)器
記錄下安裝rtmp的過(guò)程
一射亏、安裝Homebrew
確認(rèn)已經(jīng)安裝了Homebrew,可以通過(guò)brew -v查看版本的方式查看是否已經(jīng)安裝過(guò)您旁,這個(gè)不用過(guò)多解釋溉痢。
~ brew -v
Homebrew 2.1.15
Homebrew/homebrew-core (git revision fcd3; last commit 2019-10-31)
如果沒(méi)有安裝费奸,可以通過(guò)下面命令安裝:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
自然卸載命令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
如果無(wú)法安裝,也可以嘗試下下面的方法:
/bin/bash -c "$(curl -fsSL https://cdn.jsdelivr.net/gh/Homebrew/install@HEAD/install.sh)"
二谢谦、安裝nginx
安裝過(guò)程我也是網(wǎng)上查來(lái)的释牺,如果可以正常的安裝,我也就不寫(xiě)這篇筆記了回挽,首先安裝您可能搜到的步驟進(jìn)行安裝:
brew tap homebrew/nginx
結(jié)果我遇到了下面的報(bào)錯(cuò):
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.
最終在這篇博客找到了原因没咙,根查原因是因?yàn)閔omebrew/nginx的git路徑變了。因此需要使用denji/nginx命令來(lái)解決這個(gè)問(wèn)題厅各。
通過(guò)下面的命令再試試:
~ 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.
還是會(huì)報(bào)錯(cuò),仔細(xì)看錯(cuò)誤提示需要“brew unlink nginx”队塘。那么我們先執(zhí)行再說(shuō):
~ brew unlink nginx
接下來(lái)配置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;
}
#增加對(duì)HLS支持開(kāi)始
application hls {
live on;
hls on;
hls_path /usr/local/var/www/hls;
hls_fragment 5s;
}
#增加對(duì)HLS支持結(jié)束
}
}
三、啟動(dòng)nginx
到此結(jié)束憔古,我們啟動(dòng)下nginx:
~ nginx
或者是重啟:
~ nginx -s reload
瀏覽器訪問(wèn)下:http://localhost:8080遮怜,看結(jié)果是否如下圖呢:
那么 安裝過(guò)程到此完成了。
如果遇到端口被占用的問(wèn)題鸿市,可以自己搜索下解決锯梁,目前安裝過(guò)程就到此為止了即碗。