一、nginx安装
1、nginx下载
http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-1.8.1.tar.gz

2、nginx-rtmp-module模块的下载
https://github.com/arut/nginx-rtmp-module

wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
unzip nginx-rtmp-module.zip

yum -y install make gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap lsof


./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module  --add-module=/home/soft/lnmp1.3-full/src/nginx-rtmp-module-master


3、nginx 配置 点播服务器配置

worker_processes  1;

events {
    worker_connections  1024;
}
rtmp {                #RTMP服务
    server {
        listen 1935;  #//服务端口
        chunk_size 4096;   #//数据传输块的大小

        application vod {
            play /home/wwwroot/default/vod; #//视频文件存放位置。
        }
    application live{ #第一处添加的直播字段
            live on;
         hls on; #这个参数把直播服务器改造成实时回放服务器。
               wait_key on; #对视频切片进行保护,这样就不会产生马赛克了。
            hls_path /home/wwwroot/default/hls; #切片视频文件存放位置。
            hls_fragment 10s;     #每个视频切片的时长。
            hls_playlist_length 60s;  #总共可以回看的事件,这里设置的是1分钟。
            hls_continuous on; #连续模式。
            hls_cleanup on;    #对多余的切片进行删除。
            hls_nested on;     #嵌套模式。
        }
    }
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
   server {
        listen       80;
        server_name  localhost;

    location /stat {     #第二处添加的location字段。
            rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl { #第二处添加的location字段。
        root =/home/soft/lnmp1.3-full/src/nginx-rtmp-module-master;
    }
 location /live {  #这里也是需要添加的字段。
        types {  
            application/vnd.apple.mpegurl m3u8;  
            video/mp2t ts;  
        }
        alias /home/wwwroot/default/hls;   
        expires -1;
        add_header Cache-Control no-cache;  
    }

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}



然后重启后  http://120.77.13.234/stats即可


相关工具:
vlc 播放
flash_media_live_encoder_3.2 推流


==================================================
==================================================