总体来说,各个步骤以及版本参考官方文档http://nginx.org/en/docs/howto_build_on_win32.html一点没错,有些细节没说清楚。
To build nginx:
- Start MSYS bash.
- Check out nginx sources from the hg.nginx.org repository. For example: 必须使用源代码仓库中的版本,tar.gz发行包中的虽然是源码,但是不包含windows平台库,否则会提示缺少windows相关头文件
hg clone http://hg.nginx.org/nginx
- Create a build and lib directories, and unpack zlib, PCRE and OpenSSL libraries sources into lib directory:
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
- Run configure script: windows下中文简体编译的时候,先将ssl/bad_dtls_test.c编码格式改为unicode或者gb2312,否则默认警告视为错误会编译出错
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
- Run make: 在vs命令行下执行,而不是msys窗口
nmake
-
nginx.exe生成后,双击启动的时候立刻就消失了。从cmd打开执行,可以知道是少了error/conf/temp等目录所致,自己看提示应该可以解决。
参考:
http://nginx.org/en/docs/howto_build_on_win32.html
http://www.xuebuyuan.com/739815.html
https://www.itsvse.com/thread-2784-1-1.html
https://www.ruby-forum.com/topic/6875190
后面有时间开始debug继续出。