在 Win32 平台上使用 Visual C 构建 nginx
先决条件
要在 Microsoft Win32® 平台上构建 nginx,您需要:
- Microsoft Visual C编译器。已知 Microsoft Visual Studio® 8 和 10 可以正常工作。
- MSYSopen in new window。
- 如果您要构建 OpenSSL® 和有 SSL 支持的 nginx,则需要 Perl。例如 ActivePerlopen in new window 或 Strawberry Perlopen in new window。
- Mercurialopen in new window 客户端
- PCREopen in new window、zlibopen in new window 和 OpenSSLopen in new window 库源代码。
构建步骤
在开始构建之前,确保将 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
1
- 创建一个 build 和 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.2k.tar.gz
1
2
3
4
5
6
2
3
4
5
6
- 运行 configure 脚本:
auto/configure --with-cc=cl --builddir=objs --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 \
--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.2k \
--with-select_module --with-http_ssl_module
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
- 运行 make:
nmake -f objs/Makefile
1
相关内容
原文档
http://nginx.org/en/docs/howto_build_on_win32.htmlopen in new window