nginx下載地址html
http://nginx.org/en/download.htmlnginx
nginx-rtmp-module網址
https://github.com/arut/nginx-rtmp-modulegit
使用nginx 1.7.2github
錯誤以下:瀏覽器
adding module in /home/andrew/Work/tools/nginx-rtmp-module服務器
+ ngx_rtmp_module was configuredapp
checking for PCRE library ... not found測試
checking for PCRE library in /usr/local/ ... not foundui
checking for PCRE library in /usr/include/pcre/ ... not foundspa
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
須要安裝PCRE或者不支持rewrite功能
./configure --add-module=<path-to-nginx-rtmp-module> --without-http_rewrite_module
make
make install
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; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; } location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /home/andrew/Work/tools/nginx-rtmp-module; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } rtmp { server { listen 1935; chunk_size 4096; application myapp { live on; } } }
nginx配置
worker_processes 1; user root; #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; sendfile on; keepalive_timeout 18000; server { listen 80; server_name localhost; location / { root html; index index.html index.htm; client_body_temp_path /usr/local/nginx/html/tmp; } location /stat { rtmp_stat all; rtmp_stat_stylesheet stat.xsl; } location /stat.xsl { root /home/andrew/Work/tools/nginx-rtmp-module; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } rtmp { server { listen 1935; chunk_size 4096; application myapp { live on; record all; record_path /tmp/; recorder all { record all; record_suffix -%d-%b-%y-%T.flv; } } } }
啓動nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
進入/usr/local/nginx/sbin目錄,執行nginx
./nginx
打開瀏覽器輸入http://ip可看到nginx已經啓動的畫面
例如
./ffmpeg -re -i test2.flv -c:a copy -y -f flv rtmp://192.168.40.128:1935/myapp/stream1
訪問http://192.168.40.128/stat,看到如下統計信息
nginx結束
./nginx -s stop或者./nginx -s quit
一個是強制快速結束,一個是溫柔結束.
註釋:
192.168.40.128爲測試內網IP