日期:2014-05-17 浏览次数:21175 次
安装
====================
Mingw (这里先假设安装在“C:\Mingw”)
http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/
VC (这里先假设安装在“C:\Program Files\Microsoft Visual Studio 10.0”)
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express
SVN
http://tortoisesvn.net/downloads.html
?
源代码
====================
用tortoisesvn从以下地址下载Nginx源代码。
svn://svn.nginx.org/nginx/trunk
(这里先假设下载的源代码放在"C:\Nginx")
?
编译
====================
先用写字板打开"C:\MinGW\msys\1.0\msys.bat",在文件的最开头增加以下内容:
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
,然后保存文件并退出写字板。
?
双击msys.bat打开命令行窗口,
输入cl 并按回车键,看下是不是有类似于以下的输出:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation.? All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
输入nmake 并按回车键,看下是不是有类似于以下的输出:
Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.? All rights reserved.
NMAKE : fatal error U1064: MAKEFILE not found and no target specified
Stop.
?
执行以下命令切换到Nginx源代码目录:
cd /c/Nginx
?
执行以下命令生成MAKEFILE和相关的文件:
./configure --prefix= --sbin-path=nginx --with-cc=cl --with-cc-opt="-DFD_SETSIZE=1024 -wd4244 " --without-http_rewrite_module --without-http_gzip_module
这时应该有类似于以下的输出:
checking for OS
?+ MINGW32_NT-5.1 1.0.16(0.48/3/2) i686
?+ using Microsoft Visual C++ compiler
checking for MINGW32_NT-5.1 specific features
creating objs/Makefile
Configuration summary
? + PCRE library is not used
? + OpenSSL library is not used
? + md5 library is not used
? + sha1 library is not used
? + zlib library is not used
? nginx path prefix: ""
? nginx binary file: "/nginx"
? nginx configuration prefix: "/conf"
? nginx configuration file: "/conf/nginx.conf"
? nginx pid file: "/logs/nginx.pid"
? nginx error log file: "/logs/error.log"
? nginx http access log file: "/logs/access.log"
? nginx http client request body temporary files: "client_body_temp"
? nginx http proxy temporary files: "proxy_temp"
? nginx http fastcgi temporary files: "fastcgi_temp"
? nginx http uwsgi temporary files: "uwsgi_temp"
? nginx http scgi temporary files: "scgi_temp"
?
然后再执行以下命令:
nmake
这时应该有类似于以下的输出:
??????? cl -O2? -W4 -WX -nologo -MT -Zi -DFD_SETSIZE=1024 -wd4244 -Ycngx_config.h -Fpobjs/ngx_config.pch -c -I src/core? -I src/event? -I src/event/modules? -I src/os/wi
n32? -I objs? -I src/http? -I src/http/modules? -I src/mail -Foobjs/ngx_pch.obj objs/ngx_pch.c
ngx_pch.c
??????? cl -c -O2? -W4 -WX -nologo -MT -Zi -DFD_SETSIZE=1024 -wd4244 -Yungx_config.h -Fpobjs/ngx_config.pch -I src/core? -I src/event? -I src/event/modules? -I src/os/wi
n32? -I objs? -I src/http? -I src/http/modules? -I src/mail? -Foobjs/src/core/nginx.obj? src/core/nginx.c
nginx.c
??????? cl -c -O2? -W4 -WX -nologo -MT -Zi -DFD_SETSIZE=1024 -wd4244 -Yungx_config.h -Fpobjs/ngx_config.pch -I src/core? -I src/event? -I src/event/modules? -I src/os/wi
n32? -I objs? -I src/http? -I src/http/modules? -I src/mail? -Foobjs/src/core/ngx_log.obj? src/core/ngx_log.c
ngx_log.c
??????? cl -c -O2? -W4 -WX -nologo -MT -Zi -DFD_SETSIZE=1