centos7服务器搭建nginx环境,ffmpeg实现本地模拟推流

zlib、PCRE、OpenSSL






Nginx、rtmp、openssl




nginx下载地址
http://nginx.org/en/download.html
下载版本
http://nginx.org/download/nginx-1.12.2.tar.gz




下载命令
wget http://nginx.org/download/nginx-1.12.2.tar.gz








openssl下载网页
https://www.openssl.org/source/


下载地址
https://www.openssl.org/source/openssl-1.0.2n.tar.gz


下载命令


wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz



rtmp地址
https://github.com/arut/nginx-rtmp-module


下载地址
wget https://github.com/arut/nginx-rtmp-module/archive/v1.2.1.tar.gz




解压文件
tar -xzf OpenSSL_1_1_0g.tar.gz




编译openssl
找到openssl文件夹下config文件;指定生成文件目录,为当前目录下bin文件夹下,生成Makefile
./config —prefix=`pwd`/bin




编译Makefile
make install



编译openssl得到 libcrypto.so 和 libsso.so




编译nginx





编译nginx-rtmp-module
./configure —add-module=/path/to/nginx-rtmp-module      官方默认编译地址


我的环境编译地址
./configure —prefix=`pwd`/bin —add-module=/root/nginx/nginx-rtmp-module-1.2.1




/root/nginx/nginx-rtmp-module-1.2.1






——————————————————在/root/nginx/nginx-1.12.2/auto/lib/openssl/config文件中添加下面脚本,相关地址酌情修改


        if [ $ngx_found = no ]; then


            # 自定义Mac路径


            ngx_feature="OpenSSL library in /opt/local/"
    #头文件路径
            ngx_feature_path="/root/nginx/openssl-1.0.2n/bin/include"
    #头文件路径
            if [ $NGX_RPATH = YES ]; then
                ngx_feature_libs="-R/root/nginx/openssl-1.0.2n/bin/lib -L/root/nginx/openssl-1.0.2n/bin/lib -lssl -lcrypto $NGX_LIBDL"
            else
                ngx_feature_libs="-L/root/nginx/openssl-1.0.2n/bin/lib -lssl -lcrypto $NGX_LIBDL"
            fi


            . auto/feature
        fi








在nginx-1.12.2目录下,重新编译,生成Makefile
./configure —prefix=`pwd`/bin —add-module=/root/nginx/nginx-rtmp-module-1.2.1




问题一、
安装Nginx时报错
./configure:  error: the HTTP rewrite module requires the PCRE library.


安装pcre-devel解决问题
yum -y install pcre-devel






问题二、
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. 


安装openssl-devel解决问题
yum  -y install openssl openssl-devel




执行Makefile
make install






执行成功会在当前目录生成bin文件夹


在这个目录下有一个nginx可执行文件
/root/nginx/nginx-1.12.2/bin/sbin/




在/etc/ld.so.conf文件中添加nginx生成的目录
/root/nginx/nginx-1.12.2/bin


调用ldconfig命令,是上一步修改生效


启动nginx,
执行./nginx


停止nginx
./nginx -s stop






/root/nginx/nginx-1.12.2/bin/sbin




解决端口占用
sudo fuser -k 80 / tcp




开启nginx
./nginx




配置阿里云安全组
添加端口1935










使用ffmpeg模拟推流,需要下载ffmpeg工具


ffmpeg -re -i /root/f46850eb9587db185f83657d23efdc23.mp4 -f flv rtmp://ip/myapp/mystream













猜你喜欢

转载自blog.csdn.net/u010945409/article/details/79034889
今日推荐