本文共 3220 字,大约阅读时间需要 10 分钟。
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转载地址:http://scdxi.baihongyu.com/