目前直播很火,可是直播是怎麼作的呢?不少地方都有相關的教程,在這裏作一個我作的簡單的DEMO,從零開始。如下所說的服務器環境所有在Linux上。html
在服務器上下載如下源碼,截至目前這些包都是最新的。nginx
編譯安裝ide
下載完了以後你的目錄結構應該是這樣的,順序的羅列在某個文件夾下。code
nginxserver
pcre
openssl
zlib
nginx-rtmp-module
編譯
進入pcre的目錄執行命令 ./configure && make && make install
。
進入nginx的目錄執行命令
./configure --add-module=../nginx-rtmp-module --with-http_ssl_module --with-openssl=../openssl --with-zlib=../zlib make make install`。
運行
安裝好的nginx都在 /usr/local/nginx
中。
修改 /usr/local/nginx/conf/nginx.conf
文件內容:
worker_processes 1; events { worker_connections 1024; } rtmp { server { listen 1935; chunk_size 4096; application live { live on; record off; } application hls { live on; hls on; hls_path hls_temp; hls_fragment 8s; } } } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html/Love/; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }