ubuntu搭建推流服務器Nginx+rtmp [論壇 - Ubuntu 哈啦]
正在瀏覽:
1 名遊客
ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員二級
![]() ![]() 註冊日期:
2017/7/1 0:41 所屬群組:
已註冊使用者 等級: 7
HP : 0 / 152
![]() |
最近一直爬文,可能我是新手。不知道如何設定。可有人告知如何設定和安裝………謝謝
下面我自已操作過的網站,可是多不行。 http://www.jianshu.com/p/f0bf83ca3ea3 http://blog.waterlin.org/articles/using-nginx-rtmp-module-to-build-broadcast-system.html 可有那位大大可以在教我,或是看那個文……》》 我是安裝ubuntu 16.04.2
2017/7/8 22:41
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
版主
![]() ![]() 註冊日期:
2008/7/14 0:03 來自 螢幕的另一端
所屬群組:
網站管理員 已註冊使用者 討論區管理群 等級: 33
HP : 0 / 810
![]() |
不行的話,你得說你做了哪些努力,在什麼地方遇到困難、卡住了
你這麼汎汎的提問,很難有好的回應的,就算回應,也是汎汎的回應,對你的問題起不到真正的解決作用。 若你想要問到有人能從頭帶你解決這問題,更難。
2017/7/10 9:27
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
jbyziag 寫到: 先聲明,我對這部份的議題以前還沒涉略過,只是照這上面提到的參考文章來操作。 我剛剛有照「http://www.jianshu.com/p/f0bf83ca3ea3」這篇提到的步驟操作, 是可以正常編譯的。 也有照他的測試步驟來測,也是正常的, 我本來也想提,建議樓主可以提出來哪邊卡住了,可以提出來, 這樣比較有機會釐清樓主卡住的地方,看是否協助排除該因素, 因為我剛還在寫文件和範例,所以就還沒回覆,剛看到「夢見草」有先提了 夢見草 寫到: 我的系統是「Xubuntu 16.04 amd64 英文界面」。 先簡略提一下我過程中,有做修正的地方。
因為這個檔案無法下載 所以我使用「pcre-8.39.tar.gz」當關鍵字查了一下 上面的指令,可以改成下面的
後來有查了一下,關於「pcre」的網址「http://www.pcre.org/」。 裡面有列兩個下載點 * https://ftp.pcre.org/pub/pcre/ * ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 所以也可以執行下面指令下載。
================================================================================ 我的系統因為本來就有安裝「ffmpeg」,所以我就沒有照上面那篇參考文章再安裝「ffmpeg」那個步驟了。 ================================================================================ 原文中有一個路徑設定, 是「 hls_path /home/alic/www/hls;」, 我有做修改, 修改成「 hls_path /home/user/Videos/hls/www;」。 並且我也把「http」的「Document Root」路徑指到「/home/user/Videos/hls/www」這, 原本是設定在「html」,也就是路徑是「/usr/local/nginx/html」。 location / { #root html; root /home/user/Videos/hls/www; index index.html index.htm; } 然後執行下面指令 (請參考「原文範例」關於推送的第二個指令下法)
在「/home/user/Videos/hls/www」會產生
這時候只要執行下面指令 (注意:我有改「port」為「8080」,請參考下面的「nginx.conf」)
就可以看到推撥的影片(之前有寫一篇「關於「m3u」和「mpv」和「smplayer」的操作使用」)。 然後過一會剛剛產生的「/home/user/Videos/hls/www/film*」檔案就會自動清除了。 或是也可以執行下面指令,觀看影片
或是也可以執行下面指令,觀看影片
也可以透過「原文」提到的「html頁面」來播放。 先報告到這,有問題可以再提出來討論。 原來的專案「https://github.com/arut/nginx-rtmp-module」,也有「Wiki / Getting started with nginx rtmp」可以參考。 以下是參考範例。 ================================================================================ ## install.sh #!/usr/bin/env bash ## http://www.jianshu.com/p/f0bf83ca3ea3 mkdir nginx-src cd nginx-src git clone https://github.com/nginx/nginx.git git clone https://github.com/arut/nginx-rtmp-module.git #wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz wget -c https://ftp.pcre.org/pub/pcre/pcre-8.39.tar.gz tar -xzvf pcre-8.39.tar.gz cd nginx git checkout release-1.9.9 cat > cfg.sh <<EOF auto/configure \\ --prefix=/usr/local/nginx \\ --with-pcre=../pcre-8.39 \\ --with-http_ssl_module \\ --with-http_v2_module \\ --with-http_flv_module \\ --with-http_mp4_module \\ --add-module=../nginx-rtmp-module \\ EOF chmod a+x cfg.sh ./cfg.sh make sudo make install ================================================================================ ## /usr/local/nginx/conf/nginx.conf #user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { #listen 80; listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { #root html; root /home/user/Videos/hls/www; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # root html; # fastcgi_pass 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} } rtmp { server { listen 2016; #推流的監聽端口 publish_time_fix on; #推流其一 application live { live on; #stream on live allow allow publish all; # control access privilege allow play all; # control access privilege } #推流其二 application hls_alic { live on; hls on; hls_path /home/user/Videos/hls/www; hls_fragment 5s; } } } ================================================================================ ## 更多範例 * demo-nginx-rtmp / example / prototype-001 * demo-nginx-rtmp / example / demo-nginx-rtmp-002 ## 更多參考資料 查詢「hls」,可以找到一篇「直播協議 hls 筆記」。 ================================================================================ 以上提供參考 報告完畢 ![]()
2017/7/10 10:37
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員二級
![]() ![]() 註冊日期:
2017/7/1 0:41 所屬群組:
已註冊使用者 等級: 7
HP : 0 / 152
![]() |
你好,不知道你願意教我嗎?因為看你回答,和另一位大大回答。想如果有開課可以教我嗎?adiwjf@gmail.com
2017/7/10 16:13
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員二級
![]() ![]() 註冊日期:
2017/7/1 0:41 所屬群組:
已註冊使用者 等級: 7
HP : 0 / 152
![]() |
我安裝到這理就卡到了…………我要修改哪理……2位大大可以告知我嗎?
附上操作過程………word文件 麻煩,謝謝 ffmpeg這個檔案要如何安裝……
2017/7/10 16:54
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
jbyziag 寫到: 關於 jbyziag 寫到: 執行下面指令,安裝「ffmpeg」這個套件。
注意: 那個「$」,在下指令的時候,不需要貼上。 所以「原文」那有一個步驟
應該要拆成兩行
也就是
編譯安裝的操作步驟,我上面「回覆#3」有貼,您可以找尋「## install.sh」,就可以找到一段程式碼, 您可以直接複製那段的內容,到一個檔案,例如「install.sh」 然後執行下面指令,讓「install.sh」可以執行
接下來就可以執行
不然也可以執行
或是執行
正常狀況下,應該就會編譯好nginx,並且安裝到「/usr/local/nginx」這個路徑。 如何執行指令,之前有建立一個索引「 [索引]如何執行指令」,可以參考。 另外之前也有建立一個「[索引] 套件操作實務」。
2017/7/10 17:24
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員二級
![]() ![]() 註冊日期:
2017/7/1 0:41 所屬群組:
已註冊使用者 等級: 7
HP : 0 / 152
![]() |
謝謝大大我已經裝好了,執行下面指令,安裝「ffmpeg」這個套件
也和教我安裝了下面的套件,現在卡在要如何到大大所說下指令位子 正常狀況下,應該就會編譯好nginx,並且安裝到「/usr/local/nginx」這個路徑。 這我就不知如何進入了………
2017/7/11 0:03
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員五級
![]() ![]() 註冊日期:
2012/4/22 10:50 所屬群組:
已註冊使用者 等級: 37
HP : 0 / 905
![]() |
jbyziag 寫到: 先跳脫您要討論的,先來建立一些基本的概念。 執行下面指令
顯示
執行
顯示
執行
顯示
然後把剛剛執行過的三行指令,存成一個檔案,例如「test.sh」 檔案內容如下
然後您可以執行
就會顯示
這個就是「Shell Script」的概念 接下來,可以執行下面指令,設定使用者可執行
於是剛剛的「sh test.sh」就可以改成下面的指令
一樣會顯示
然後剛剛的「test.sh」,也可以在第一行加上「Shebang (中文)」。 所以上面的「test.sh」的內容,就可以改成下面的
或是改成
或是改成
除了剛剛的「Shebang (中文)」的規則, 若是「#」後面則是「註解」 所以「test.sh」改成下面的內容
然後執行
還是顯示
一些討論案例紀錄在「[索引]如何執行指令」。 ================================================================================ jbyziag 寫到: 接下來回到正題。 您可以參考您提供的「參考文章」, 一個指令一個指令下,可以嘗試瞭解每個指令所作的動作,要達成什麼目標。 假設您登入的帳號「jbyziag」, 所以當您登入的時候,通常家目錄會是在「/home/jbyziag」這個路徑, 通常也可以使用「~」或「$HOME」來表示「/home/jbyziag」這個路徑。 若是使用「root」這個帳號來登入,通常的家目錄則是「/root」。 以下以帳號「jbyziag」這個帳號登入來舉例。 執行下面指令,在家目錄產生一個資料夾「project」,也就是「/home/jbyziag/project」這個路徑。
執行下面指令,切換到「~/project」,也就是切換到「/home/jbyziag/project」
執行下面指令,
就會顯示
================================================================================ 接下來,我把上面「回覆#3」的 「install.sh」一個指令一個指令拆解,也就是原本「參考文章」的步驟。 執行下面指令,產生資料夾「nginx-src」,也就是「/home/jbyziag/project/nginx-src」這個路徑
執行下面指令,切換到資料夾「nginx-src」,也就是切換到「/home/jbyziag/project/nginx-src」這個路徑
您可以執行「pwd」,確認您是否在「/home/jbyziag/project/nginx-src」這個路徑。 接下來執行下面指令,clone「https://github.com/nginx/nginx.git」下來。
上面clone完成後,應該會有一個資料夾「nginx」,內容就是「https://github.com/nginx/nginx」列的。 路徑就是「/home/jbyziag/project/nginx-src/nginx」。 接下來執行下面指令,clone「https://github.com/arut/nginx-rtmp-module.git」下來。
上面clone完成後,應該會有一個資料夾「nginx-rtmp-module」,內容就是「https://github.com/arut/nginx-rtmp-module」列的。 路徑就是「/home/jbyziag/project/nginx-src/nginx-rtmp-module」。 接下來執行下面指令,會下載「https://ftp.pcre.org/pub/pcre/pcre-8.39.tar.gz」這個檔案。
若是有完整下載,會有一個檔案「pcre-8.39.tar.gz」, 路徑就是「/home/jbyziag/project/nginx-src/pcre-8.39.tar.gz」。 接下來執行下面指令,解開「pcre-8.39.tar.gz」。
解開後就會看到一個資料夾「pcre-8.39」, 路徑就是「/home/jbyziag/project/nginx-src/pcre-8.39」。 所以現在有四個路徑 * /home/jbyziag/project/nginx-src/nginx * /home/jbyziag/project/nginx-src/nginx-rtmp-module * /home/jbyziag/project/nginx-src/pcre-8.39 * /home/jbyziag/project/nginx-src/pcre-8.39.tar.gz 目前在「/home/jbyziag/project/nginx-src/」這個路徑, 接下來執行下面指令,切換到「nginx」這個資料夾, 也就是切換到「/home/jbyziag/project/nginx-src/nginx」這個路徑。
接下來執行下面指令,「checkout release-1.9.9」。
接下來執行下面指令,產生「cfg.sh」這個檔案。 路徑就是「/home/jbyziag/project/nginx-src/nginx/cfg.sh」。 cat > cfg.sh <<EOF auto/configure \\ --prefix=/usr/local/nginx \\ --with-pcre=../pcre-8.39 \\ --with-http_ssl_module \\ --with-http_v2_module \\ --with-http_flv_module \\ --with-http_mp4_module \\ --add-module=../nginx-rtmp-module \\ EOF 上面這個動作是我修改的,原來的「參考文章」 是用「vim」開啟,然後請您填入如下面的內容。 您也可以用自己慣用的編輯器來編輯「cfg.sh」這個檔案。 auto/configure --prefix=/usr/local/nginx \ --with-pcre=../pcre-8.39 \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_flv_module \ --with-http_mp4_module \ --add-module=../nginx-rtmp-module/ 接下來執行下面指令,設定「cfg.sh」可執行。
接下來執行下面指令,也就是執行「cfg.sh」。
接下來執行「make」來編譯「nginx」。
上面是根據「Makefile」這個檔案,也就是根據「/home/jbyziag/project/nginx-src/nginx/Makefile」這個檔案 上面可以成功編譯完成的話, 接下來執行下面指令,就會安裝「nginx」到「/usr/local/nginx」這個路徑。
可以執行下面指令,來觀看「/usr/local/nginx」這個資料夾的結構。
顯示 /usr/local/nginx/ ├── conf │ ├── fastcgi.conf │ ├── fastcgi.conf.default │ ├── fastcgi_params │ ├── fastcgi_params.default │ ├── koi-utf │ ├── koi-win │ ├── mime.types │ ├── mime.types.default │ ├── nginx.conf │ ├── nginx.conf.default │ ├── scgi_params │ ├── scgi_params.default │ ├── uwsgi_params │ ├── uwsgi_params.default │ └── win-utf ├── html │ ├── 50x.html │ └── index.html ├── logs └── sbin └── nginx 4 directories, 18 files 您要設定的是「/usr/local/nginx/conf/nginx.conf」, 若要啟動「nginx」,則是要執行「/usr/local/nginx/sbin/nginx」。 上面「tree」這個指令,要執行「sudo apt-get install tree」安裝「tree」這個套件。 ================================================================================ 上面「回覆#6」和「回覆#3」, 我提到,就是直接把上面的步驟,寫成一個檔案,例如「install.sh」。 然後執行下面指令,設定「install.sh」可執行。
執行下面指令,執行「install.sh」。
================================================================================ 另外寫了一個「範例」, 不同的地方,在於「nginx」安裝的路徑,改安裝到「/usr/local/share/nginx」, 然後「HTTP Document Root」的路徑「/usr/local/share/nginx/html」, 而「RTMP HLS」的路徑,則是設定到「/usr/local/share/nginx/html/hls」。 ================================================================================ 以上釐清 報告完畢 ![]()
2017/7/11 16:11
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員二級
![]() ![]() 註冊日期:
2017/7/1 0:41 所屬群組:
已註冊使用者 等級: 7
HP : 0 / 152
![]() |
今天,到台中一日遊。明天我在測試。如我操作發生問題在麻煩大大你.....謝謝
2017/7/12 19:42
|
||||||||||
![]() |
回覆: ubuntu搭建推流服務器Nginx+rtmp |
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
會員二級
![]() ![]() 註冊日期:
2017/7/1 0:41 所屬群組:
已註冊使用者 等級: 7
HP : 0 / 152
![]() |
大大你好:
為何我下指令sh test.sh 不會出現 yes or no 而我下指令 pwd 也不會出現 /home/jbyziag/project 而出現 root/project 為何沒有/home呢? 麻煩大大告知
2017/7/13 16:37
|
||||||||||
![]() |
您可以查看帖子.
您不可發帖.
您不可回覆.
您不可編輯自己的帖子.
您不可刪除自己的帖子.
您不可發起投票調查.
您不可在投票調查中投票.
您不可上傳附件.
您不可不經審核直接發帖.