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

构建步骤
参见

先决条件

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

  • Microsoft Visual C 编译器。已知 Microsoft Visual Studio 8、10、17 可以工作。®
  • MSYSMSYS2
  • Perl,如果您想构建支持 SSL 的 OpenSSL 和 nginx。 例如 ActivePerlStrawberry Perl®
  • Git 客户端。
  • PCREzlibOpenSSL 库源。

构建步骤

确保将 Perl、Git 和 MSYS bin 目录的路径添加到 PATH 环境变量。设置 Visual C 环境 从 Visual C 目录运行vcvarsall.bat脚本。

要构建 nginx:

  • 启动 MSYS bash。
  • 从 GitHub 存储库中查看 nginx 源代码:
    git clone https://github.com/nginx/nginx.git
    
  • 创建 build 和 lib 目录,并解压缩 zlib、PCRE 和 OpenSSL 库 sources 添加到 lib 目录中:
    mkdir objs
    mkdir objs/lib
    cd objs/lib
    tar -xzf ../../pcre2-10.39.tar.gz
    tar -xzf ../../zlib-1.3.1.tar.gz
    tar -xzf ../../openssl-3.0.14.tar.gz
    
  • 运行 configure 脚本:
    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/pcre2-10.39 \
        --with-zlib=objs/lib/zlib-1.3.1 \
        --with-openssl=objs/lib/openssl-3.0.14 \
        --with-openssl-opt=no-asm \
        --with-http_ssl_module
    
  • 运行 make:
    nmake
    

另请参阅