`
ssxxjjii
  • 浏览: 935838 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

使用Nginx架设高性能流媒体服务器

 
阅读更多

 

 

http://wgkgood.blog.51cto.com/1192594/1285887

前言*随着Nginx大量被各互联网公司使用,常见的Nginx用来做反向代理WEB服务器、缓存服务器,nginx应用很广泛,今天我们来研究一下使用Nginx架设高性能流媒体服务器

一、系统环境

1
2
3
系统版本:CentOS 5.8x86_64
Nginx版本: Nginx-1.4.2.tar.gz
Yamdi版本:Yamdi-1.9.tar.gz

二、自动化安装

Linux采用自动化安装非常便捷,快速,而且这也每个Linux SA必须掌握的,直接上代码,欢迎大家提更好的意见,让脚本更有实用性。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#Auto Make Install Nginx FLV MP4 Server
#系统版本:CentOS 5.8 x86_64
#Nginx版本: Nginx-1.4.2.tar.gz
#Yamdi版本:Yamdi-1.9.tar.gz
#Define Path
SRC_DIR=/usr/src
NGX_DIR=/usr/local/nginx/
CODE=0
SOFT_URL=(
                                                                           
    http://nginx.org/download/nginx-1.4.2.tar.gz
                                                                           
    http://downloads.sourceforge.net/project/yamdi/yamdi/1.9/yamdi-1.9.tar.gz
                                                                           
    http://chinaapp-wordpress.stor.sinaapp.com/uploads/2013/08/player.swf
                                                                           
)
if
    $UID  -ne $CODE ];then
    echo "Must to be use Root Exec Shell ......"
    exit 0
                                                                          
fi
for i  in  `echo ${SOFT_URL[0]} ${SOFT_URL[1]} ${SOFT_URL[2]} `
                                                                        
    do
                                                                           
    cd  $SRC_DIR  ;wget $i
                                                                           
    if
        "$?" == "$CODE" ];then
                                                                           
        echo "---------The $i Soft Download Success ! "
                                                                           
    else
                                                                             
        echo "---------The $i Soft Download Success ! "
                                                                        
    fi
                                                                          
done
#Nginx install Include Flv Mp4
cd  $SRC_DIR ; tar -xzf  nginx-1.4.2.tar.gz ;cd nginx-1.4.2 && ./configure  --prefix=/usr/local/nginx --with-http_gzip_static_module  --with-http_stub_status_module  --with-http_flv_module --with-http_mp4_module && make &&make install
if
    "$?" == "$CODE" ];then
    echo "The Nginx  Make install Success ! "
else
    echo "The Nginx  Make install Failed ! "
fi
#Install  Yamdi Tools
    cd  $SRC_DIR ; tar -xzf  yamdi-1.9.tar.gz ;cd yamdi-1.9/ &&make &&make install
#Config Nginx Service And Flv
    cp  wugk.mp4 player.swf  /usr/local/nginx/html/
                                                                            
    /usr/local/bin/yamdi -i 51cto.mp4 -o wugk.mp4
    grep -E "(flv|mp4)" $NGX_DIR/conf/nginx.conf
    [ $?  -eq  $CODE ]&&sed -i '46c \\tlocation ~ \.flv$ {\n\tflv;\n\t}\n\tlocation ~ \.mp4$ {\n\tmp4;\n\t}' /usr/local/nginx/conf/nginx.conf
                                                                           
#start Nginx service
    $NGX_DIR/sbin/nginx -t
    [ $?  -eq  $CODE ]&&/usr/local/nginx/sbin/nginx
    IP=`ifconfig eth0|grep "Bcast" |awk -F":" '{print $2}'|cut -d" " -f 1`
    echo "All Config Successful , You Can Use http://$IP/player.swf?type=http&file=wugk.mp4 to access nginx flv server !!"
    exit 1

三、测试验证

(1)、脚本执行效果:

(2)、视频访问效果:

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics