dannyliao 2017-1-2 15:28
在 ubuntu 16.04 上安裝 nginx rtmp server 影片串流伺服器Streaming
這裡介紹使用Ubuntu 16.04 安裝 nginx 架設 RTMP 串流伺服器,不過我只用到 Video On Demand。<br>研究到後來才發現.原來這個解決方案主要是搭配線上直播用.如果只是要做影片串流,就用HTML5 的 Video 標籤就好了. <br><br># apt-get install build-essential libpcre3 libpcre3-dev libssl-dev unzip software-properties-common libexpat-dev libgd-dev libgeoip-dev libluajit-5.1-dev libmhash-dev libpam0g-dev libperl-dev libxslt1-dev autotools-dev debhelper po-debconf dh-systemd<br># apt-get install nginx nginx-extras<br><br>步驟1: Get nginx apt source & build-dep<br># apt-get update<br># apt-get install dpkg-dev<br># mkdir -p build ; cd build<br># apt-get source nginx<br># apt-get build-dep nginx<br><br>步驟2: Git clone nginx-rtmp-module source<br># git clone git://github.com/arut/nginx-rtmp-module.git<br><br>步驟3: 編輯 debian/rules<br># cd nginx-1.10.0/<br># vi debian/rules<br>增加 --add-module=/root/build/nginx-rtmp-module 這一行 (下述紅字部分)<br><br>[quote]<br>...<br>extras_configure_flags := \<br>$(common_configure_flags) \<br>--with-http_addition_module \<br>--with-http_dav_module \<br>--with-http_flv_module \<br>--with-http_geoip_module \<br>--with-http_gunzip_module \<br>--with-http_gzip_static_module \<br>--with-http_image_filter_module \<br>--with-http_mp4_module \<br>--with-http_perl_module \<br>--with-http_random_index_module \<br>--with-http_secure_link_module \<br>--with-http_v2_module \<br>--with-http_sub_module \<br>--with-http_xslt_module \<br>--with-mail \<br>--with-mail_ssl_module \<br>--with-stream \<br>--with-stream_ssl_module \<br>--with-threads \<br>--add-module=$(MODULESDIR)/headers-more-nginx-module \<br>--add-module=$(MODULESDIR)/nginx-auth-pam \<br>--add-module=$(MODULESDIR)/nginx-cache-purge \<br>--add-module=$(MODULESDIR)/nginx-dav-ext-module \<br>--add-module=$(MODULESDIR)/nginx-development-kit \<br>--add-module=$(MODULESDIR)/nginx-echo \<br>--add-module=$(MODULESDIR)/ngx-fancyindex \<br>--add-module=$(MODULESDIR)/nginx-http-push \<br>--add-module=$(MODULESDIR)/nginx-lua \<br>--add-module=$(MODULESDIR)/nginx-upload-progress \<br>--add-module=$(MODULESDIR)/nginx-upstream-fair \<br>--add-module=$(MODULESDIR)/ngx_http_substitutions_filter_module<font color="Red"> \</font><br><font color="Red">--add-module=/root/build/nginx-rtmp-module</font><br>...<br>[/quote]<br><br>步驟4: 開始編譯/build package<br># dpkg-buildpackage -b<br><br>步驟5: 安裝 package<br># cd ..<br># dpkg --install nginx-extras_1.10.0-0ubuntu0.16.04.4_amd64.deb<br><br>(Reading database ... 208049 files and directories currently installed.)<br>Preparing to unpack nginx-extras_1.10.0-0ubuntu0.16.04.2_amd64.deb ...<br>Unpacking nginx-extras (1.10.0-0ubuntu0.16.04.2) over (1.10.0-0ubuntu0.16.04.2) ...<br>Setting up nginx-extras (1.10.0-0ubuntu0.16.04.2) ...<br>Processing triggers for man-db (2.7.5-1) <br><br>步驟6: 重新啟動 nginx<br># service nginx restart<br># systemctl status nginx.service<br><br>步驟7: 設定 nginx.conf<br># vi /etc/nginx/nginx.conf<br>[quote]<br>....<br>rtmp {<br>server {<br>listen 1935;<br>notify_method get;<br>buflen 100ms;<br>chunk_size 65536;<br>timeout 60s;<br>max_streams 1024;<br><br># Video on demand<br>application vod {<br>play /var/www/html/video;<br>}<br>}<br>}<br>...<br>[/quote]<br><br>網頁檔:<br>請到這個地方下載網頁語法<br>http://flash.flowplayer.org/plugins/streaming/rtmp.html<br><br>參考資料:<br>http://lexra.pixnet.net/blog/post/176386325-how-to-rebuild-ubuntu-nginx-package-and-install-with-nginx-r<br>https://docs.peer5.com/guides/setting-up-hls-live-streaming-server-using-nginx/