安装nginx本觉得很容易的事,结果把我整惨了,一开始按照提示的错误,q去下载了各种依赖包,包括zlib-1.2.4 ,openssl-0.9.8,pcre等,并手动编译,安装。。。* m2 I; W2 S) V1 Q$ V# V+ \
进入Ningx目录configure时,本以为这条命令能大功告成,$ j3 i. s% F) Z2 a. Y- U
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/openssl-0.9.8 --with-md5=/usr/local/openssl-0.9.8 --with-zlib=/usr/local/zlib-1.2.4 --user=www --group=www8 m! u" I- R) B# v! g
结果出现的各种错误,调了我一晚上,错误顺序记不清了,大概有如下些错误:# P0 K! ^' {2 |8 X' G. R% e
“./configure: error: the HTTP cache module requires md5 functions, E4 S# k( D8 r
from OpenSSL library. You can either disable the module by using
& E. G7 D$ X- |8 }- b( ]6 j--without-http-cache option, or install the OpenSSL library into the system,3 C; `# u7 q! U$ a' ?
or build the OpenSSL library statically from the source with nginx by using* p; T" U% Q) j4 a: @. O( {3 \
--with-http_ssl_module --with-openssl=<path> options.”
! W4 x" r8 D) g- A% N& p解决办法:按照说明的加上--with-http_ssl_module --with-openssl=<path>。! S0 ]. F/ `& E- {7 O
make时出现的错误:4 g; o4 |0 T+ C$ {
“make -f objs/Makefile8 @! }" \* o2 U% a
make[1]: Entering directory `/home/nginx-0.7.65'2 b% ^. _# {1 `& t
cd /usr/local/pcre \- t' @! f7 S; p9 Y1 `* t1 r
&& if [ -f Makefile ]; then make distclean; fi \: v; o2 P, x$ F
&& CC="gcc" CFLAGS="" \. L6 P% `- T4 i, d5 j
./configure --disable-shared
" z0 P2 o% G0 B* ?6 e5 @/bin/sh: line 2: ./configure: 没有那个文件或目录
$ k- _/ Y( d6 `( Q4 wmake[1]: *** [/usr/local/pcre/Makefile] 错误 127
m' u5 H, r" y8 B& Xmake[1]: Leaving directory `/home/nginx-0.7.65'
: s! Y1 P* i/ hmake: *** [build] 错误 2”% a4 P$ E8 C; r8 ^
解决办法,把手动安装的pcre卸了,make uninstall就行,然后让机器安装yum install pcre-devel版,
4 b% A5 f: \$ p( S去掉--with-pcre=/....# j# B* G' H0 e
“make[1]: Entering directory `/home/nginx-0.7.65'
4 z( \, U8 H' \. f- t9 p) vcd /usr/local/openssl-0.9.8 \
- Y+ }' S0 C+ s' ~5 s1 @* m6 H&& make clean \
" R# P6 x. ]% F/ w/ ^- J0 R&& ./config --prefix=/usr/local/openssl-0.9.8/.openssl no-shared no-threads \% x* Y% ]2 c* T
&& make \
4 O: N2 a: B1 X8 G: S+ d&& make install9 D. W- W1 y( v" @8 _) |5 y
make[2]: Entering directory `/usr/local/openssl-0.9.8'
& a+ Y1 A8 Y9 n+ B, l- dmake[2]: *** 没有规则可以创建目标“clean”。 停止。
! L( t7 K4 g# T* M: g! K3 o$ ?/ n8 ~0 ]- _make[2]: Leaving directory `/usr/local/openssl-0.9.8'
$ G2 j0 A% F% s8 Dmake[1]: *** [/usr/local/openssl-0.9.8/.openssl/include/openssl/ssl.h] 错误 2
* P" X2 w3 X1 j3 j c( q/ c& }4 d! `make[1]: Leaving directory `/home/nginx-0.7.65'9 w4 p/ G. ^$ J7 M: z
make: *** [build] 错误 2”
$ h! g4 R9 K8 o! ~7 x& u9 e这个问题由于--with-http_ssl_module依赖MD5而取不到引起,若去掉--with-http_ssl_module后不行,同样用yum install openssl-devel,然后再去掉--with-http_ssl_module. E5 ?3 t+ a# q- i1 W+ A2 G( r+ [3 B
“ && make libz.a
+ s* f6 W B6 w$ j# c( Pmake[2]: Entering directory `/usr/local/zlib-1.2.4'/ O* }$ n d5 Q5 X
make[2]: *** 没有规则可以创建目标“clean”。 停止。4 J e4 g/ @ `
make[2]: Leaving directory `/usr/local/zlib-1.2.4'6 `. \: W) D9 }9 C
make[1]: *** [/usr/local/zlib-1.2.4/libz.a] 错误 2
. N" Q) X7 e8 h; zmake[1]: Leaving directory `/home/nginx-0.7.65'
+ ~% f0 \8 C* xmake: *** [build] 错误 2”
; \1 Q8 z1 Y' s) d( w$ v由于上面机器自动安装时安装了zlib, 所以再去掉--with-zlib=/usr/local/zlib-1.2.4。9 O& {: b+ v& J1 j
最后,./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-openssl=/usr/local/openssl-0.9.8 --user=www --group=www 才终于成功了。3 F* E8 A p* h+ y) w/ D3 B ?
把问题贴出来,好让有同样遭遇的初学者参考。; E' J/ w, @) G; ]/ d0 a0 Y
经验告诉我们,能默认装就装默认的吧,手动安装费时费神啊!
转载于:https://www.cnblogs.com/mashuaimama/archive/2012/04/15/2450030.html