Building nginx on the Win32 platform with Visual C

原文链接:http://nginx.org/en/docs/howto_build_on_win32.html

在Win32平台上使用Visual C编译nginx

必备条件:

要在微软Win32平台上编译nginx,你需要以下环境或源码:

  • 微软Visual C编译器. Microsoft Visual Studio®8 和 10 等已知可正常运行的版本。
  • MSYS.
  • Perl, 如何你想编译OpenSSL以使nginx能支持SSL的话. 比如: ActivePerlStrawberry Perl.
  • Mercurial 客户端(译者注:源码拉取工具,如果已有源码就没必要安装了。).
  • PCRE, zlibOpenSSL三个库代码。(译者注:PCRE未正则表达式库,zlib为支持http传输进行gzip压缩支持库,OpenSSL为SSL访问支持库)。

编译步骤:

在你编译之前请确保讲Perl, Mercurial跟MSYS的bin目录添加到了系统的PATH环境变量中。从Visual C目录下运行vcvarsall.bat脚本以便可以获取Visual C的编译环境。

开始编译nginx:

  • 启动MSYS bash.
  • 从hg.nginx.org代码库中检出nginx源码。示例:
    hg clone http://hg.nginx.org/nginx
    
  • 新建一个编译目录和lib库目录, 然后解压zlib, PCRE和OpenSSL三个库的源码到lib库目录中:
    mkdir objs
    mkdir objs/lib
    cd objs/lib
    tar -xzf ../../pcre-8.41.tar.gz
    tar -xzf ../../zlib-1.2.11.tar.gz
    tar -xzf ../../openssl-1.0.2n.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/pcre-8.41 \
        --with-zlib=objs/lib/zlib-1.2.11 \
        --with-openssl=objs/lib/openssl-1.0.2n \
        --with-openssl-opt=no-asm \
        --with-select_module \
        --with-http_ssl_module
    
  • 运行make命令:
    nmake
    

翻译完了,不过觉着官方的编译手册有些老了,仅供参考吧。。。

我的两篇相关博客:

WIN10+VS2017环境下编译nginx-1.12及rtmp module备忘 

VS2017使用项目管理编译Nginx与RTMP Module

猜你喜欢

转载自blog.csdn.net/xinxinsky/article/details/79950204
今日推荐