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