CentOS 6.4 x86_64系统,编译安装nginx 1.4.5。

./configure时先是提示需要pcre的lib文件。用rpm -qa | grep pcre看了一下,pcre-7.8-6.el6.x86_64是已经安装过的。

于是用--with-pcre=/lib64指定了pcre的.so文件路径。但是在make的时候提示如下错误

make -f objs/Makefile 
make[1]: Entering directory `/usr/local/src/nginx-1.4.5′ 
cd /usr/local/pcre / 
       && if [ -f Makefile ]; then make distclean; fi / 
       && CC="gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " / 
       ./configure –disable-shared 
/bin/sh: line 2: ./configure: No such file or directory 
make[1]: *** [/usr/local/pcre/Makefile] Error 127 
make[1]: Leaving directory `/usr/local/src/nginx-1.4.5′ 
make: *** [build] Error 2

用./configure --help看了一下,原来“--with-pcre=”参数要指定的是源码文件。百度了一下也有说是要下个pcre的源码包指定路径过去。

我觉得既然已经安装过一个pcre了,还要在编译安装一个实在有点儿蛋疼。。所以自己倒腾了一下,发现其实并不用再找源码包编译,只要把pcre-devel装上就OK。安装完成后,./configure参数改成--with-pcre,不要=和后面的路径。

还有SSL的支持也是需要openssl-devel的。(这个yum装把,用rpm会被依赖关系搞到蛋疼)


总结一下,nginx编译安装基本上需要以下几个东东:

1.gcc-----------------必不可少的

2.zlib-----------------gzip需要

3.openssl(包括openssl-devel)-----SSL支持需要

4.pcre(包括pcre-devel)--------让nginx支持正则表达式


我最后用的./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre --with-http_ssl_module

看到以下显示这一步就成功了

Configuration summary
 + using system PCRE library
 + using system OpenSSL library
 + md5: using OpenSSL library
 + sha1: using OpenSSL library
 + using system zlib library

后面愉快的make && make install把!