下载nginx源码
https://github.com/nginx/nginx
下载工具集
MinGW:https://osdn.net/projects/mingw/releases/
Perl :https://www.activestate.com/products/perl/downloads/
nasm:https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D 记得添加环境变量
sed:https://sourceforge.net/projects/gnuwin32/files/sed/4.2.1/ 记得添加环境变量
lib下三方库
nginx-http-flv-module:https://github.com/winshining/nginx-http-flv-module
openssl:http://distfiles.macports.org/openssl/ 选择1.0.版本的,听说1.1.版本会出问题
zlib:https://zh.osdn.net/projects/sfnet_libpng/downloads/zlib/1.2.11/zlib-1.2.11.tar.gz/
pcre:https://ftp.pcre.org/pub/pcre/
编译
1.新建文件夹nginx-flv,并解压nginx源码到nginx-flv下
2.在nginx-flv下新建文件夹build,进入build,在build下新建文件夹3rdlib和output
3.将nginx-http-flv-module,openssl,zlib,pcre解压缩到nginx-flv/build/3rdlib目录下
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 #本行很重要,如果只编译nginx可不要本行
5.打开mingw控制台
路径:mingw安装文件夹\msys\1.0\msys.bat 点击msys.bat即可
6.以管理员身份打开VS2019 命令提示工具进入nginx-flv目录
命令窗口路径
1.打开 开始菜单栏
2.找到Visual Studio 2019
3.选择x64 Native Tools Command Prompt for VS2019
进入nginx-flv目录(怎么切换文件夹,自己搜一下哈)
进行编译
编译成功后
文件修改
1.nginx-flv\auto\lib\openssl\mkaefile.msvc
有三处修改,如图所示
- 1
- 2
2.build\output\Makefile
将-W4 -WX 改为 -W3