一:前期准备工作
下载Nginx wget
http://nginx.org/download/nginx-1.12.1.tar.gz
下载Openssl wget https://github.com/openssl/openssl/archive/OpenSSL_1_1_0f.tar.gz
二:编译并配置服务器
1、新建一个nginx 文件夹用来存放 Nginx Openssl Rtmp 并进行解压
2、编译Openssl
2.1、新建一个bin目录
2.2、./config --prefix=`pwd`/bin
会在当前目录下生成Makefile 文件
2.3、执行 make install
会发现我们新建的bin目录下有以下的文件夹 ,include 跟lib 是我们所需的
3、编译Nginx
3.1、进入 nginx-1.12.1 文件夹
3.2 进入 auto/lib/openssl/conf 配置脚本
3.3、
修改cof
文件 vim conf
修改如下
# 自己加入一行判断 一定要是自己编译出来的路径
if [ $ngx_found = no ]; then
# FreeBSD port
# FreeBSD port
ngx_feature="OpenSSL library in /usr/local/"
ngx_feature_path="/nginx/openssl-OpenSSL_1_1_0f/bin/include"
if [ $NGX_RPATH = YES ]; then
ngx_feature_libs="-R/nginx/openssl-OpenSSL_1_1_0f/bin/lib -L/usr/local/lib -lssl -lcrypto $NGX_LIBDL"
else
ngx_feature_libs="-L/nginx/openssl-OpenSSL_1_1_0f/bin/lib -lssl -lcrypto $NGX_LIBDL"
fi
. auto/feature
fi
3.4、
回到nginx
目录下
3.5、./configure --prefix=`pwd`/bin --add-module=/nginx/nginx-rtmp-module-1.2.0
编译之后就会出现Mikefile 文件
3.6、正真编译 make install (Make
之后
会多一个bin
目录
就代表成功了)
3.7、进入bin/sbin 下 执行 ./nginx
3.8、
将nginx-rtmp-module/test/
下的nginx.conf
复制到 nginx/bin/conf
下面 并重启服务
如果开启了
先关闭nginx
服务器
修改配置
将nginx-rtmp-module/test/
下的nginx.conf
复制到 nginx/bin/conf
下面
当前在nginx-rtmp-module/test/
目录下执行
cp nginx.conf /root/nginx/nginx-1.12.1/bin/conf/
使用ffmpeg-20170915-6743351-win64-static 进行推流
ffmpeg -re -i F:\xxx.flv -f flv rtmp://192.168.1.169/myapp/mystream
使用vlc 进行直播
安装过程中可能遇到的错误
错误一:
error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
在vim /etc/ld.so.conf
加入 /nginx/openssl-OpenSSL_1_1_0f/bin/lib
Ldconfig
运行刚刚的配置
错误二
开启出现找不到ssl动态库错误
配置linux库查找目录
/etc/ld.so.conf
添加一行,指向openssl库目录
/root/nginx/openssl-OpenSSL_1_1_0f/bin
刷新: ldconfig
错误三:
报pcre 错误 就 安装pcre
获取pcre编译安装包,在http://www.pcre.org/上可以获取当前最新的版本
解压缩pcre-xx.tar.gz包。
进入解压缩目录,执行./configure。
make & make install
错误四 zlib
获取zlib编译安装包,在http://www.zlib.net/上可以获取当前最新的版本。
解压缩openssl-xx.tar.gz包。
进入解压缩目录,执行./configure。
make & make install
阿里云服务器要配置安全组 开启1935 8080 8081 端口