在制作xServer集成环境Windows版过程中,发现官方编译版组件较少,故自行从源码编译了Nginx,下面为详细步骤。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
一、下载如下文件
VS2008
http
:
//download.microsoft.com/download/3/0/2/3025EAE6-2E15-4972-972A-F5B1ED248E85/VS2008ExpressWithSP1CHSX1504735.iso
Perl
http
:
//strawberry-perl.googlecode.com/files/strawberry-perl-5.16.3.1-32bit.msi
Mercurial
http
:
//mercurial.selenic.com/downloads/
MinGW
http
:
//sourceforge.net/projects/mingw/files/latest/download
OpenSSL
http
:
//www.openssl.org/source/openssl-1.0.1e.tar.gz
Pcre
http
:
//nchc.dl.sourceforge.net/project/pcre/pcre/8.32/pcre-8.32.zip
Zlib
http
:
//zlib.net/zlib-1.2.8.tar.gz
subs_filter
https
:
//codeload.github.com/yaoweibin/ngx_http_substitutions_filter_module/zip/master
二、编译
nginx
1、安装
VS2008、
Perl、
Mercurial,分别对应
C
++编译环境、
Perl脚本运行时、
Hg源码仓库客户端
2、安装
MinGW管理器,添加
MSYS模块,其他模块可以不安装,用于生成
Makefile文件
a、使用
C
:
\
Program
Files
\
Microsoft
Visual
Studio
9.0
\
VC
\
bin
\
link
.
exe
替换
C
:
\
MinGW
\
msys
\
1.0
\
bin
\
link
.
exe
b、编辑
C
:
\
MinGW
\
msys
\
1.0
\
msys
.
bat
在
@
echo
off下面加入:
call
"C:\Program Files\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
3、将
OpenSSL、
Pcre、
Zlib
分别解压到目录
c
:
\
nginx
\
objs
\
lib
\
{
openssl
-
1.0.1e
,
pcre
-
8.32
,
zlib
-
1.2.8
}
中
4、检出
nginx源码,命令:
hg
clone
--
verbose
--
http
:
//hg.nginx.org/nginx c:\nginx
a
.编辑
c
:
\
nginx
\
src
\
core
\
nginx
.
h
修改服务器名称
b
.替换
c
:
\
nginx
\
src
\
os
\
win32
\
nginx
.
ico
自定义软件图标
c
.将
subs
_filter
解压到
c
:
\
nginx
\
objs
\
module
\
http_subs
_filter
编辑文件
ngx_http_subs_filter_module
.
c,将
ngx_regex_compile_t
rc
;
移动到当前函数顶部,否则编译出错
5、把下面命令写入到
c
:
\
nginx
\
mkngx,然后在
msys中执行该文件
auto
/
configure
--
with
-
cc
=
cl
--
builddir
=
objs
--
prefix
=
--
sbin
-
path
=
nginx
.
exe
--
conf
-
path
=
conf
/
nginx
.
conf
\
--
pid
-
path
=
logs
/
nginx
.
pid
--
http
-
log
-
path
=
logs
/
access
.
log
--
error
-
log
-
path
=
logs
/
error
.
log
\
--
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
-
select_module
--
with
-
ipv6
--
with
-
mail
\
--
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_random_index_module
--
with
-
http_secure_link
_module
\
--
with
-
pcre
=
objs
/
lib
/
pcre
-
8.32
--
with
-
zlib
=
objs
/
lib
/
zlib
-
1.2.8
--
with
-
openssl
=
objs
/
lib
/
openssl
-
1.0.1e
\
--
with
-
openssl
-
opt
=
enable
-
tlsext
--
with
-
http_ssl_module
--
with
-
mail_ssl
_module
\
--
add
-
module
=
objs
/
module
/
http_subs_filter
mkdir
objs
/
{
conf
,
logs
}
nmake
-
f
objs
/
Makefile
6、执行上述步骤时可能会提示找不到
stdin
.
h文件
编辑
c
:
\
nginx
\
objs
\
lib
\
pcre
-
8.32
\
config
.
h,删除如下内容
#ifndef HAVE_INTTYPES_H
#define HAVE_INTTYPES_H 1
#endif
#ifndef HAVE_STDINT_H
#define HAVE_STDINT_H 1
#endif
|