安装nginx时遇到的问题及解决方案
今天在安装nginx时出现如下错误:
[root@node1 nginx-0.8.55]# ./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
报错信息:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
上面步骤很明显缺少了一个叫pcre的库文件,安装好后并指定路径,我们接着安装。
[root@node1 pcre-8.02]# ./configure --prefix=/usr/local/pcre
[root@node1 pcre-8.02]# make && make install
安装正常后,我们接着安装nginx。
[root@node1 nginx-0.8.55]# ./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--with-pcre=/usr/local/pcre
当使用make
时报了如下错误:
[root@node1 nginx-0.8.55]# make
make -f objs/Makefile
make[1]: Entering directory `/nginx/nginx-0.8.55'
cd /usr/local/pcre && if [ -f Makefile ]; then make distclean; fi && CC="gcc" CFLAGS="" ./configure --disable-shared
/bin/sh: line 2: ./configure: 没有那个文件或目录
make[1]: *** [/usr/local/pcre/Makefile] 错误 127
make[1]: Leaving directory `/nginx/nginx-0.8.55'
make: *** [build] 错误 2
通过查阅资料发现,原来在检测环境时,nginx的configure脚本指向的不是pcre的安装后目录,而是指向了pcre的源目录。正确的做法应该是指向pcre的安装目录,如下所示:
[root@node1 nginx-0.8.55]# ./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--with-pcre=/usr/local/pcre-8.02
[root@node1 nginx-0.8.55]# make && make install
OK! 安装成功。