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
- user www www; ##管理用户
- worker_processes 8; ##后台进程
- error_log /usr/local/nginx/logs/error.log; ##nginx错误日志存放路径
- pid /usr/local/nginx/logs/nginx.pid;
- events {
- use epoll;
- ##轮训方式
- worker_connections 65535;
- ##允许的最大连接数
- }
- http {
- include mime.types;
- default_type application/octet-stream;
- log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- '$status $body_bytes_sent "$http_referer" '
- '"$http_user_agent" "$http_x_forwarded_for"';
- access_log /usr/local/nginx/logs/access.log;
- sendfile on;
- tcp_nopush on;
- #keepalive_timeout 0;
- keepalive_timeout 65;
- gzip on;
- server {
- listen 80;
- server_name localhost;
- root /usr/local/nginx/html ;
- #charset koi8-r;
- limit_rate_after 1m;
- limit_rate 256k;
- charset utf-8;
- access_log /usr/local/nginx/logs/host.access.log main;
- location / {
- root html;
- index index.html index.htm;
- # limit_rate_after 5m;
- # limit_rate 512k;
- }
- #error_page 404 /404.html;
- location ~ \.flv$ {
- flv;
- }
- location ~ \.mp4$ {
- mp4;
- }
- location ~(favicon.ico) {
- log_not_found off;
- expires 30d;
- break;
- }
修改完成后保存退出。
启动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