windows编译nginx
钢翼
编程
参考 http://nginx.org/en/docs/howto_build_on_win32.html
1.下载MSYS
https://sourceforge.net/projects/mingw/files/Installer/
运行后,将Basic Setup的包都安装上
2.下载Strawberry Perl
https://strawberryperl.com/
在环境变量PATH中添加perl.exe所在bin目录
3.下载nginx源码
http://hg.nginx.org/nginx 选择zip下载并解压
4.下载PCRE、zlib 和OpenSSL
https://ftp.pcre.org/pub/pcre/
http://zlib.net/
https://www.openssl.org/source/
下载并解压到/nginx源码目录下的/objs/lib,目录结构如下
D:
└──nginx
└──objs
└──lib
└──openssl-1.1.1k
└──pcre-8.45
└──zlib-1.2.11
5.生成Makefile
双击d:/MinGW/msys/1.0/msys.bat
在msys控制台执行以下命令
记得objs/lib下的版本号要对应上
cd /d/nginx
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.2.11 \
--with-openssl=objs/lib/openssl-1.1.1k \
--with-openssl-opt=no-asm \
--with-http_ssl_module \
--with-http_sub_module
6.编译nginx
使用vs的vc命令行执行编译命令
x86 Native Tools Command Prompt for VS 20XX
cd d:/nginx
nmake
可能会报'sed' 不是内部或外部命令,也不是可运行的程序不过没什么影响