windows下编译nginx-http-flv-moudle

一: 编译前准备

1:msys(1.0.11内含mingw命令行工具)

2:perl (ActivePerl 5.28,草莓版好像会编译出错,具体原因不知)

3:nasm(2.11.02)

4:sed

安装完之后,配置正确的环境变量。

5:nginx-http-flv-moudle

6:zlib(1.2.11,Zlib是一个压缩和解压模块)

7:openssl(1.1.1d,加密)

8:pcre(8.3.4perl语言兼容正则表达式)

二:开始编译

1:windows先安装vs,若已安装跳过。未安装则请安装vs2017社区版本,并配置相关环境变量。(vs编译 nmake命令,安装社区版vs2017,企业版不行,会出现nmake命令不可用),以下是本机配置的环境变量

添加vs环境变量(包含LIB INCLUDE),详见教程
https://blog.csdn.net/kaige_zhao/article/details/80315697
例如:
path变量
D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX64\x64

LIB变量
D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\lib\x64

INCLUDE变量
D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include;D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include

2:编译

2.1 新建文件夹nginx-flv并解压nginx源码到nginx-flv下

2.2 在nginx-flv下新建文件夹build,进入build,在build下新建文件夹3rdlib和output

2.3.将nginx-http-flv-module,openssl,zlib,pcre解压缩到nginx-flv/build/3rdlib目录下

在这里插入图片描述

2.4.在nginx-flv目录下新建build.bat文件并输入以下脚本

auto/configure --with-cc=cl --builddir=build/output --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-flv.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=build/3rdlib/pcre-8.34
–with-zlib=build/3rdlib/zlib-1.2.11 --with-openssl=build/3rdlib/openssl-1.0.1u

–with-select_module --with-http_ssl_module
–add-module=build/3rdlib/nginx-http-flv-module-master
(* 加粗部分为本地文件的路径,如果版本与本文不一致记得修改)

2.5 最终整个编译工程的目录构架如下

nginx-flv
├─auto
├─build
│ ├─3rdlib
│ │ ├─nginx-http-flv-module-master
│ │ ├─openssl-1.0.1u
│ │ ├─pcre-8.34
│ │ └─zlib-1.2.11
│ └─output
├─conf
├─contrib
├─docs
├─misc
├─src
└─build.bat

2.6.打开mingw命令行工具进入nginx-flv目录执行build.bat

cd F:/nginx-flv // 这里不是Windows风格的命令,必须使用F:/nginx-flv,而不能使用F:\nginx-flv

build.bat // 运行build.bat文件,这个挺耗时的,大约几分钟吧,结束后会在nginx-flv/build/output目录下生成Makefile,运行结束如下图
在这里插入图片描述
如执行nmake /f build/output/Makefile 报错如下图:
在这里插入图片描述
修改nginx\auto\lib\openssl\makefile.msvc文件:
将VC-WIN32改为VC-WIN64A,将ms\do_ms 改为ms\do_win64a

进入D:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build文件夹下,双击运行vcvarsall.bat文件。

切换openssl版本为1.1.1d,继续执行nmake命令,报错

解决办法:
修改C:\Perl64\lib\ActivePerl\Config.pm,大约在400行左右,屏蔽sub_marn里面的代码。

Vs本机命令提示符工具 到nginx-flv目录下 执行nmake命令
执行成功。

到此,编译完成。目录下生成了 makefile文件和nginx.exe,双击nginx.exe可以启动nginx,并将nginx原版的相关目录拷贝过来,如下图
在这里插入图片描述
最后本机的nginx.conf文件内容如下:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;

    #default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
    
    server {
        listen       80;

        location / {
            root D:/javaTools/zzcc-visual-ui/zzcc-visual-ui/build;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
            add_header 'Access-Control-Allow-Origin' '*';
        }

        location /fcloud {
          root  D:/ruihai/resources/local-cloud;
          add_header 'Access-Control-Allow-Origin' '*';
        }
    }

    server {
        listen       85;
        
         location /flv {
            flv_live on; #打开HTTP播放FLV直播流功能
            chunked_transfer_encoding on; #支持'Transfer-Encoding: chunked'方式回复

            add_header 'Access-Control-Allow-Origin' '*'; #添加额外的HTTP头
            add_header 'Access-Control-Allow-Credentials' 'true'; #添加额外的HTTP头
        }

        location /hls {      
           types{    
             application/vnd.apple.mpegurl m3u8;    
             video/mp2t ts;    
           }    
        alias /test;    
        expires -1;    
        }
      
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root html/nginx-http-flv-module/;
        }

        location /control {
            rtmp_control all;
        }

        location /rtmp-publisher {
            root html/nginx-http-flv-module/test;
        }

        #access_log  logs/host.access.log  main;

        #location / {
          #root html/nginx-http-flv-module/test/www;
          #index  index.html index.htm;
        #}

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
   
    }

}

rtmp {  
    server {  
        listen 1935;  
        chunk_size 4000;  
        application hls { 
            live on;
            record off;
            hls on;
            hls_path /test;
            hls_fragment 1s;
        }  
    }  
}

创作不易,点个关注支持以下把!

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 10
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 10
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值