Windows10下编译Nginx64位并增加Ipv6模块

需要的源码/依赖/工具包

  1. nginx1.17.5,github地址:https://github.com/nginx/nginx/archive/release-1.17.5.zip
  2. openssl-1.0.2t,openssl地址:https://www.openssl.org/source/openssl-1.0.2t.tar.gz
  3. pcre-8.43,Pcre地址:https://ftp.pcre.org/pub/pcre/pcre-8.43.zip
  4. zlib-1.2.11,Zlib地址:http://www.zlib.net/zlib-1.2.11.tar.gz
  5. msys64,MSYS2地址:https://mirrors.tuna.tsinghua.edu.cn/msys2/distrib/x86_64/msys2-x86_64-20190524.exe
  6. Perl64,Perl地址:https://softpedia-secure-download.com/dl/83d98a70bcf3be67d3c938720e8654c4/5db02538/100069258/software/programming/ActivePerl-5.28.1.2801-MSWin32-x64-24563874.exe
  7. NASM,nasm地址:https://www.nasm.us/pub/nasm/releasebuilds/2.12.02rc9/win64/nasm-2.12.02rc9-installer-x64.exe
  8. Microsoft Visual Studio 自行下载社区版,这里使用的是2017

解压/安装各文件并配置目录信息

  1. 解压 nginx1.17.5openssl-1.0.2tpcre-8.43zlib-1.2.11四个包,然后在Nginx根目录下新建objs/lib目录,把openssl/pcre/zlib三个目录移至该目录中(其中关于nginx源码,必须从github或者其它管代码管理库中下载,在官网下载的源码包中缺失了src\os\win32这个目录)
  2. 安装msys64Perl64NASM

修改源码

  1. 打开 nginx\auto\lib\openssl\makefile.msvc
    修改第9行VC-WIN32,改为VC-WIN64A
    修改第14行ms\do_ms.bat,改为ms\do_win64a.bat
    修改第15行ms\do_ms,改为ms\do_win64a
  2. 打开nginx-1.17.5\auto\cc\msvc
    在第16行添加NGX_MSVC_VER=15.00或者直接注释掉第117/118/119几行

生成Makefile

打开刚刚安装的msys64,切换到nginx源码目录,执行以下命令:

auto/configure \
--with-cc=cl \
--builddir=objs \
--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.43 \
--with-zlib=objs/lib/zlib-1.2.11 \
--with-select_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_stub_status_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_slice_module \
--with-mail --with-stream \
--with-openssl=objs/lib/openssl-1.0.2t \
--with-openssl-opt=no-asm \
--with-http_ssl_module \
--with-mail_ssl_module \
--with-stream_ssl_module \
--with-ipv6 \
--with-http_v2_module

生成结果如下:
在这里插入图片描述
然后找到VS的安装路径,进入到VC\Auxiliary\Build目录,用CMD打开vcvars64.bat文件(PowerShell打开不行,必须用cmd。。。),然后跳转到nginx源码目录执行 nmake -f objs/Makefile
执行过程中会报很多警告,只要不报错就OK,结果如下:
在这里插入图片描述
最后会提示 ‘sed’ 不是内部或外部命令,也不是可运行的程序 ,不要紧,这个时候你的objs目录中应该已经生成了nginx.exe.文件了,咱看看版本信息:
在这里插入图片描述

然后在下载http://nginx.org/download/nginx-1.17.5.zip 官方版,把官方版中的nginx.exe替换成我们自己编译的版本。启动试试~

参考:https://blog.csdn.net/silent_missile/article/details/99317811

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值