nginx安装及依赖关系的配置记录

来源:互联网 发布:淘宝爆款挖掘机软件 编辑:程序博客网 时间:2024/06/06 20:17

一、pcre安装

./configure --prefix=/usr/local/pcre-8.38 --libdir=/usr/local/lib/pcre --includedir=/usr/local/include/pcre
--libdir=DIR
  指定库文件的安装位置.
--includedir=DIR
  指定C头文件的安装位置.其他语言如C++的头文件也可以使用此选项.

二、安装zlib

./configure --prefix=/usr/local/zlib-1.2.8
三、安装ssl

./config --prefix=/usr/local/openssl-1.0.1s

进入nginx源码根目录:

./configure --prefix=/usr/local/nginx --with-pcre=</usr/local/pcre-8.38> --with-zlib=</usr/local/zlib-1.2.8> --with-openssl=</usr/local/openssl-1.0.1s> --add-module=</usr/local/src/nginx-rtmp-module> --with-debug


auto/configure--add-module=<path-to-nginx-rtmp-module>

make -f objs/Makefile

make -f objs/Makefile install

 

增加:http_ssl_module:

auto/configure--add-module=<path-to-nginx-rtmp-module> --with-http_ssl_module


简介

Nginx本身是一个非常出色的HTTP服务器 FFMPEG是非常好的音视频解决方案 这两个东西通过一个nginx的模块nginx-rtmp-module组合在一起 即可以搭建一个功能相对比较完善的流媒体服务器

这个流媒体服务器可以支持RTMP和HLS(Live Http Stream)

环境

1.Ubuntu2.Git3.Gcc

Nginx、Nginx-rtmp-module及依赖工具包的安装

下载并解压

1. Nginx下载地址:http://nginx.org/en/download.html2. Nginx-rtmp-module下载地址:https://github.com/arut/nginx-rtmp-module.git3. PCRE下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/4. OPENSSL下载地址:ftp://ftp.openssl.org/source/5. ELIB:http://www.zlib.net/

配置参数

配置依赖工具

./configure --prefix=/usr/local/nginx --with-pcre=<pcre位置> --with-zlib=<zlib位置> --with-openssl=<openssl位置>

配置Nginx-rtmp-module

./configure --add-module=<nginx-rtmp-module位置> --with-debug //with ddebug, 打开调试模式makemake install

默认会安装到 /usr/local/nginx/ 但是有可能会提示权限不足 而不能创建相应的文件目录, 这时候要么用sudo 去执行或者更改/usr/local/目录的权限。

修改Configure文件

进入/usr/local/nginx/conf,打开nginx.conf 加入RTMP配置

rtmp {     server {         listen 1935;          application myapp {             live on;         }         application hls {             live on;             hls on;             hls_path /tmp/hls;         }     }  }

针对HLS还需要在HTTP中加入

location /hls {             types {                 application/vnd.apple.mpegurl m3u8;                 video/mp2t ts;             }             root /tmp;             add_header Cache-Control no-cache;  }

日志的添加

sudo vim nginx.conf;

打开调试模式:

error_log /home/saxon/works/rtmp/ngix/rtmp_stream.log debug; //在协议提外就会是所有的日志都用此配置#by songbai add rtmp live modulertmp {   server {        #error_log /home/saxon/works/rtmp/ngix/rtmp_stream.log debug;//可以在协议提覆盖配置, 但是rtmp这里好像有问题, http没有问题        listen 1935;        chunk_size 4000;        application  live {                   live on;        }    }}error_log /home/saxon/works/rtmp/ngix/rtmp_stream.log debug;

运行

进入/usr/local/nginx/sbin

sudo ./nginx

浏览器输入localhost,看见welcome页面,成功启动

停止

./nginx -s stop或者./nginx -s quit(会给nginix缓冲时间去回收相关的资源)


0 0
原创粉丝点击