windows10下编译部署nginx-http推流服务器

准备工作

  1. nginx源代码
https://nginx.org/download/nginx-1.24.0.tar
  1. nginx-http-flv-module
https://github.com/winshining/nginx-http-flv-module
  1. PCRE, zlib and OpenSSL
https://sourceforge.net/projects/pcre/files/pcre/8.45/
https://zlib.net/current/zlib.tar.gz
https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz

将nginx解压到一个文件夹,并在其中新建objs文件夹,将其余四个文件复制到objs/lib中(注:不建议有目录中有中文名称)
在这里插入图片描述

编译

安装MSYS2 MSYS,该工具可在windows环境下提供编译功能

https://www.msys2.org/

进入到目录下
在这里插入图片描述
执行以下命令,这里要注意objs文件夹下的路径要写对,如果下载版本和我的不一致,需要对应修改文件名

auto/configure \
    --with-cc=cl \
    --with-debug \
    --prefix= \
    --conf-path=conf/nginx.conf \
    --pid-path=logs/nginx.pid \
    --http-log-path=logs/access.log \
    --error-log-path=logs/error.log \
    --sbin-path=nginx.exe \
    --http-client-body-temp-path=temp/client_body_temp \
    --http-proxy-temp-path=temp/proxy_temp \
    --http-fastcgi-temp-path=temp/fastcgi_temp \
    --http-scgi-temp-path=temp/scgi_temp \
    --http-uwsgi-temp-path=temp/uwsgi_temp \
    --with-cc-opt=-DFD_SETSIZE=1024 \
    --with-pcre=objs/lib/pcre-8.45 \
    --with-zlib=objs/lib/zlib-1.3.1 \
    --with-openssl=objs/lib/openssl-1.1.1c \
    --with-openssl-opt=no-asm \
    --add-module=objs/lib/nginx-http-flv-module \
    --with-http_ssl_module

出现以下内容即表示成功。在这里插入图片描述
打开x86 Native Tools Command Prompt for VS 2022,来到nginx目录,输入nmake,如果出现以下问题,说明需要安装perl
在这里插入图片描述
重新编译,最后编译成功
在这里插入图片描述补充,sed为linux指令,需要单独安装并配置环境变量

配置

在nginx目录下新建文件夹logs、temp。将objs目录下的nginx.exe复制到nginx目录下,根据以下内容完成配置,即可启动。

worker_processes  1;

events {
    worker_connections  1024;
}

rtmp_auto_push on;            
rtmp_auto_push_reconnect 1s;            
rtmp {             
    server {             
        listen 1935;  #监听的端口号            
        chunk_size 8192; # 单一推流数据包的最大容量                      
        application dfx {  # 创建rtmp应用hls            
            live on;  # 当路径匹配时,开始播放            
            allow publish 127.0.0.1;
            allow play all;
       }             
    }            
}   

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;

        location /dfx {
            flv_live on;  # 启用 HTTP-FLV
        }
        location /flv {
            add_header 'Access-Control-Allow-Origin' '*';  # 允许跨域
            flv_live on;
            chunked_transfer_encoding on;  # 启用分块传输编码
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

参考链接:https://blog.csdn.net/byna11sina11/article/details/117735684

附:本文提供已编译完成的推流服务器压缩包,可直接运行使用。下载资源即可获取

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

孤妄~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值