使用nginx构建rtmp服务器

1. 1, 编译环境搭建。
sudo apt-get install g++
sudo apt-get -y install autoconf automake build-essential libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libssl-dev

2.下载安装相关库
(1) pcre-8.32
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
tar -zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make
make install

(2)zlib 为了gzip压缩
http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make
make install

(3)
http://www.openssl.org/source/openssl-1.0.1f.tar.gz
tar -zxvf openssl-1.0.1f.tar.gz
./config
make
make install
在安装时如果出现如下错误:POD document had syntax errors at /usr/bin/pod2man line 69. make .那么,解决如下:
rm /usr/bin/pod2man


(4)nginx_mod_h264_streaming-2.2.7
http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz
tar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gz

(5)nginx-rtmp-module
https://github.com/arut/nginx-rtmp-module
unzip nginx-rtmp-module-master

(6)
http://nginx.org/download/nginx-1.5.9.tar.gz
tar -zxvf nginx-1.5.9.tar.gz

./configure \
--prefix=/usr/local/nginx/ \
--add-module=../nginx-rtmp-module-1.0.2 \
--with-http_ssl_module \
--add-module=../nginx_mod_h264_streaming-2.2.7 \
--with-pcre=../pcre-8.32 \
--with-zlib=../zlib-1.2.8  \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_mp4_module  

make

make install

可能遇到问题1
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function ‘ngx_streaming_handler’:
/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c:158: error: ‘ngx_http_request_t’ has no member named ‘zero_in_uri’
make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1
make[1]: Leaving directory `/root/nnginx-1.5.9'
make: *** [build] Error 2
那么将src/ngx_http_streaming_module.c文件中以下代码删除或者是注释掉就可以了:

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

可能遇到问题2
../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘esds_read’中:

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:377:16: 错误: 变量‘stream_priority’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:376:12: 错误: 变量‘stream_id’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c: 在函数‘stsd_parse_vide’中:

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:529:22: 错误: 变量‘level_indication’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:528:22: 错误: 变量‘profile_compatibility’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:527:22: 错误: 变量‘profile_indication’被设定但未被使用 [-Werror=unused-but-set-variable]

../nginx_mod_h264_streaming-2.2.7/src/mp4_reader.c:526:22: 错误: 变量‘configuration_version’被设定但未被使用 [-Werror=unused-but-set-variable]

cc1: all warnings being treated as errors

make[1]: *** [objs/addon/src/mp4_reader.o] 错误 1

解决方法:
# vim objs/Makefile (修改objs/Makefile文件, 去掉其中的"-Werror"), 然后就能够正常编译了.


(7) 然后 cd /usr/local/nginx
启动  ./nginx
优雅关闭   ./nginx -s quit
快速关闭   ./nginx -s stop


nginx -s reload  :修改配置后重新加载生效
nginx -s reopen  :重新打开日志文件
nginx -t -c /path/to/nginx.conf 测试nginx配置文件是否正确


(8) 浏览器打开 localhost 就能看到欢迎的界面
命令行:lynx localhost
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值