使用 Visual C 在 Win32 平台上构建 Nginx

Prerequisites

要在 MicrosoftWin32®平台上构建 nginx,您需要:

Build steps

开始构建之前,请确保将 Perl,Mercurial 和 MSYS bin 目录的路径添加到 PATH 环境变量中。要设置 Visual C 环境,请从 Visual C 目录运行 vcvarsall.bat 脚本。

要构建 nginx:

  • 启动 MSYS bash。

  • 从 hg.nginx.org 存储库中签出 nginx 源。例如:

hg clone http://hg.nginx.org/nginx
  • 创建一个 build 和 lib 目录,然后将 zlib,PCRE 和 OpenSSL 库源代码解压缩到 lib 目录中:
mkdir objs
mkdir objs/lib
cd objs/lib
tar -xzf ../../pcre-8.44.tar.gz
tar -xzf ../../zlib-1.2.11.tar.gz
tar -xzf ../../openssl-1.1.1g.tar.gz
  • 运行配置脚本:
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.44 \
    --with-zlib=objs/lib/zlib-1.2.11 \
    --with-openssl=objs/lib/openssl-1.1.1g \
    --with-openssl-opt=no-asm \
    --with-http_ssl_module
  • Run make:
nmake

See also