1.环境:

操作系统:centos 5.5

软件:

1.nginx-1.3.5.tar.gz

2.nginx_mod_h264_streaming-2.2.7.tar.gz

3.pcre-8.12.zip

4.zlib-1.2.3.tar.gz

5.yamdi-1.8.tar.gz 

6.JW Player播放器

    get http://blogimg.chinaunix.net/blog/upfile2/100607142612.rar

安装步骤:

1.首先将上诉5个软件放到linux下/usr/local/src/nginx-source目录下。

2.安装zlib

 cd /usr/local/src/nginx-source

 tar -zxvf zlib-1.2.3.tar.gz

cd zlib-1.2.3

./configure

make

make install

3.安装prce

cd ..

tar zxvf pcre-8.12.tar.gz 

cd pcre-8.12

 

./configure 

make && make install

 

4.解压nginx_mod_h264_streaming-2.2.7.tar.gz

cd ..

tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz

修改相关信息,不然后边编译安装的时候会出问题。

cd nginx_mod_h264_streaming-2.2.7/src

vi ngx_http_streaming_module.c

删除以下几行信息,或者注释掉也可以。

/* TODO: Win32 */
if (r->zero_in_uri)
{
return NGX_DECLINED;
}

5.安装nginx

tar zxvf nginx-1.3.5.tar.gz

cd nginx-1.3.5

./configure  --add-module=/usr/local/src/nginx-source/nginx_mod_h264_streaming-2.2.7  --with-pcre=/usr/local/src/nginx-source/pcre-8.12 --with-zlib=/usr/local/src/nginx-source/zlib-1.2.3  --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-openssl-opt=enable  --with-http_mp4_module  --with-cc-opt='-O3'

make 

make install

6.配置nginx

首先用命令/usr/local/nginx/sbin/nginx -V 命令来查看nginx安装是否正确。

/usr/local/nginx/sbin/nginx -V

--add-module=/usr/local/src/nginx-source/nginx_mod_h264_streaming-2.2.7  --with-pcre=/usr/local/src/nginx-source/pcre-8.12 --with-zlib=/usr/local/src/nginx-source/zlib-1.2.3  --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-openssl-opt=enable  --with-http_mp4_module  --with-cc-opt='-O3'

配置nginx.conf

cd /usr/local/nginx/conf/

cp nginx.conf nginx.conf.bak

vi nginx.conf

 

 
  
  1. user  www www;  ##管理用户 
  2.  
  3. worker_processes 8;    ##后台进程 
  4.  
  5. error_log  /usr/local/nginx/logs/error.log; ##nginx错误日志存放路径 
  6.  
  7. pid        /usr/local/nginx/logs/nginx.pid; 
  8.  
  9. events { 
  10.  
  11.         use epoll; 
  12.  
  13. ##轮训方式 
  14.  
  15.         worker_connections      65535; 
  16.  
  17. ##允许的最大连接数 
  18.  
  19.         } 
  20.  
  21. http { 
  22.  
  23.     include       mime.types; 
  24.  
  25.     default_type  application/octet-stream; 
  26.  
  27.   
  28.  
  29.     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ' 
  30.  
  31.                       '$status $body_bytes_sent "$http_referer" ' 
  32.  
  33.                       '"$http_user_agent" "$http_x_forwarded_for"'
  34.  
  35.   
  36.  
  37.     access_log  /usr/local/nginx/logs/access.log; 
  38.  
  39.   
  40.  
  41.     sendfile        on
  42.  
  43.     tcp_nopush     on
  44.  
  45.   
  46.  
  47.     #keepalive_timeout  0; 
  48.  
  49.     keepalive_timeout  65; 
  50.  
  51.   
  52.  
  53.     gzip  on
  54.  
  55.   
  56.  
  57.     server { 
  58.  
  59.         listen       80; 
  60.  
  61.         server_name  localhost; 
  62.  
  63.         root /usr/local/nginx/html ; 
  64.  
  65.         #charset koi8-r; 
  66.  
  67.         limit_rate_after 1m; 
  68.  
  69.         limit_rate  256k; 
  70.  
  71.          charset utf-8; 
  72.  
  73.         access_log  /usr/local/nginx/logs/host.access.log  main; 
  74.  
  75.   
  76.  
  77.         location / { 
  78.  
  79.             root   html; 
  80.  
  81.             index  index.html index.htm; 
  82.  
  83.            # limit_rate_after 5m; 
  84.  
  85.            # limit_rate  512k; 
  86.  
  87.         } 
  88.  
  89.         #error_page  404              /404.html; 
  90.  
  91.        location ~ \.flv$ { 
  92.  
  93.                          flv; 
  94.  
  95.                         } 
  96.  
  97.        location ~ \.mp4$ { 
  98.  
  99.                          mp4; 
  100.  
  101.                         } 
  102.  
  103.        location ~(favicon.ico) { 
  104.  
  105.                         log_not_found off
  106.  
  107.                         expires 30d; 
  108.  
  109.                         break; 
  110.  
  111.                                } 

修改完成后保存退出。

启动nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

7.准备flv视频文件,并插入关键帧,支持拖拽播放。

cd /usr/local/src/nginx-source

tar zxvf yamdi-1.8.tar.gz 

cd yamdi-1.8

./configure

make 

make install

将第6个软件(jw Player )解压,然后把player.swf传到/usr/local/nginx/html/目录下,

给视频注入关键帧

yamdi -i /usr/local/nginx/html/123.flv -o /usr/local/nginx/html/321.flv

8播放测试

http://192.168.109.152/player.swf?type=http&file=321.flv