使用php開發簡單的線上直播服務端(一)-前期準備(writing...2016-12-29更新)
阿新 • • 發佈:2019-01-07
本次開發兩個版本,分別為使用swoole拓展和不使用swoole拓展。只是一個個人能力鍛鍊的娛樂小專案O(∩_∩)O~。
技術配置
- Mac OS系統
- PHP7.1
- swoole拓展(非必需)
- nginx-rtmp
- mongodb
- Video.js
- React.js
- ffmpeg
1.使用homebrew安裝php7.1和swoole拓展
安裝php7.1
brew install php71 --with-cgi --with-homebrew-libressl --with-homebrew-libxml2 --with-pear --with-thread -safety --without-fpm --without-pcntl
檢視php7.1拓展
$ brew search php71
搜尋結果
安裝swoole拓展
$ brew install homebrew/php/php71-swoole
測試是否安裝成功
<?php
if (!extension_loaded('swoole')){
exit("Please install swoole extension. \n");
}
安裝pthreads拓展(可能用到)
2.Homebrew安裝nginx+rtmp伺服器
開始安裝
$ brew tap homebrew/nginx
$ brew install nginx-full --with-rtmp-module
$ nginx
啟動檢查
$ lsof -i tcp:8080
$ kill pid #pid為對應程序pid
修改nginx.conf
查詢nginx.conf
$ brew info nginx #找到nginx.conf相關字眼
$ vim /usr/local/etc/nginx/nginx.conf
在末尾加入
rtmp {
server {
listen 1935 ;
application rtmplive {
live on;
record off;
}
}
}
修改完畢後
$ nginx -s reload #重新載入配置檔案
nginx配置到此為止
3.Homebrew安裝ffmpeg
$ brew install ffmpeg
4.Homebrew安裝mongodb
$ brew install mongodb