
课题_nginx搭建rtmp协议流媒体服务器总结.docx
10页nginx搭建rtmp协议流媒体服务器总结最近在ubuntu12.04上搭建了一个rtmp服务器,感觉还挺麻烦的,所以记录下大部分都是参考网络上的资料前提:在linux下某个目录中新建一个nginx目录然后进入该目录去下载搭建环境所需要的一些资源包此处在/root/目录下新建一个nginx目录即:/root/nginx/1、 安装依赖包:#yum -y install gcc glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_642、 安装相关工具包1) . git# mkdir soft-source# cd soft-source# wget ://codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.xz# xz -d git-latest.tar.xz# tar xzvf git-latest.tar# cd git-2014-06-27# autoconf# ./configure# make && make install# git --versiongit version 2.0.0.GIT# cd ..2) . zlib# wget :// tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8# ./configure# make# make install# cd ..3) . pcre# wget ://exim.mirror.fr/pcre/pcre-8.12.tar.gz# tar zxvf pcre-8.12.tar.gz# cd pcre-8.12# ./configure# make && make install# cd ..4) . yadmiyadmi的作用是为flv文件添加关键帧,才能实现拖动播放# wget :// tar xzvf download# cd yamdi-1.4# make && make install# cd ..使用方法:# yamdi -i input.flv -o out.flv给input.flv文件 添加关键帧,输出为out.flv文件5) . OpenSSL# wget ://.openssl.org/source/openssl-1.0.1c.tar.gz# tar -zxvf openssl-1.0.1c.tar.gz# ./config# make# make install3、 安装ffmpeg及其依赖包:1) . Yasm# wget :// tar xzvf yasm-1.2.0.tar.gz# cd yasm-1.2.0# ./configure# make# make install# cd ..2) . x264# git clone git://git.videolan.org/x264# cd x264# ./configure --enable-shared# make# make install# cd ..3) . LAME# wget :// tar xzvf lame-3.99.5.tar.gz# cd lame-3.99.5#./configure --enable-nasm# make# make install# cd ..4) . libogg# wget ://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz# tar xzvf libogg-1.3.0.tar.gz# cd libogg-1.3.0# ./configure# make# make install# cd ..5) . libvorbis# wget ://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz# tar xzvf libvorbis-1.3.3.tar.gz# cd libvorbis-1.3.3# ./configure# make# make install# cd ..6) . libvpx# git clone ://git.chromium.org/webm/libvpx.git# cd libvpx# ./configure --enable-shared# make# make install# cd ..7) . FAAD2# wget :// tar zxvf faad2-2.7.tar.gz# cd faad2-2.7# ./configure# make# make install# cd ..8) . FAAC# wget :// tar zxvf faac-1.28.tar.gz# cd faac-1.28# ./configure# make# make install# cd ..注:编译时可能遇到一下错误:mpeg4ip.h:126: error: new declaration ‘char* strcasestr(const char*, const char*)’ 解决方法:从123行开始修改此文件mpeg4ip.h,到129行结束。
修改前:#ifdef __cplusplusextern "C" {#endifchar *strcasestr(const char *haystack, const char *needle);#ifdef __cplusplus}#endif修改后:#ifdef __cplusplusextern "C++" {#endifconst char *strcasestr(const char *haystack, const char *needle);#ifdef __cplusplus}#endif9) . Xvid# wget ://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz# tar zxvf xvidcore-1.3.2.tar.gz# cd xvidcore/build/generic# ./configure# make# make install# cd ..10) . ffmpeg# git clone git://source.ffmpeg.org/ffmpeg# cd ffmpeg# ./configure --prefix=/opt/ffmpeg/ --enable-version3--enable-libvpx --enable-libfaac --enable-libmp3lame--enable-libvorbis --enable-libx264 --enable-libxvid--enable-shared --enable-gpl --enable-postproc --enable-nonfree--enable-avfilter --enable-pthreads# make && make install# cd ..修改/etc/ld.so.conf 如下:include ld.so.conf.d/*.conf/lib/lib64/usr/lib/usr/lib64/usr/local/lib/usr/local/lib64/opt/ffmpeg/lib# ldconfig二、安装Nginx相关模块1. 模块安装# wget ://h264.code- tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz# git clone git:// 创建用户和组# groupadd# useradd -g3. nginx 安装# wget ://nginx.org/download/nginx-1.6.0.tar.gz# tar zxvf nginx-1.6.0.tar.gz# cd nginx-1.6.04. 编译安装nginx在 nginx-1.6.0 目录下新建文件:nginx_configure.sh然后使用gedit打开进行编辑:#!/bin/shecho "configure start ..."./configure \--prefix=/usr/local/nginx \--sbin-path=/usr/local/nginx/nginx \--conf-path=/usr/local/nginx/nginx.conf \--pid-path=/usr/local/nginx/nginx.pid \--error-log-path=/usr/local/nginx/logs/error.log \--add-module=../nginx_mod_h264_streaming-2.2.7 \--with-pcre=../pcre-8.12 \--with-zlib=../zlib-1.2.8 \--with-_dav_module \--with-_flv_module \--with-_stub_status_module \--without-_scgi_module \--without-_uwsgi_module \--without-_gzip_module \--without-_ssi_module \--without-_proxy_module \--without-_memcached_module \--without-_empty_gif_module \--without-mail_pop3_module \--without-mail_ima。












