依次安装:
1、安装GCC-C++,安装Pcre的时候需要
[...]# yum install -y gcc gcc-c++
2、安装pcre-8.38.zip官网下载即可,安装nginx的时候需要
[...]# cp /mnt/hgfs/tttmp/pcre-8.38.tar.gz /opt/
[...]# gzip -d pcre-8.38.tar.gz
[...]# tar xvf pcre-8.38.tar
[...]# cd pcre-8.38
[...]# ./configure --prefix=/usr/local/pcre-8.38
[...]# make
[...]# make install
3、安装Zlib,安装nginx的时候需要
[...]# cp -a /mnt/hgfs/tttmp/zlib-1.2.8.tar.gz /opt/
[...]# gzip -d zlib-1.2.8.tar.gz
[...]# tar xvf zlib-1.2.8.tar
[...]# cd zlib-1.2.8
[...]# ./configure --prefix=/usr/local/zlib
[...]# make
[...]# make install
4、安装完以上的几个组件后,可正常安装Nginx了
[...]# gzip -d nginx-1.8.1.tar.gz
[...]# tar xvf nginx-1.8.1.tar
[...]# cd nginx-1.8.1
[...]# ./configure --prefix=/usr/local/nginx
[...]# make
[...]# make install
但是我在执行 ./configure --prefix=/usr/local/nginx 此命令的时候仍然报错:
error:
./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.
之后如下处理,即可正常安装:
[...]# ./configure --prefix=/usr/local/nginx/ --with-pcre=/opt/pcre-8.38 --with-zlib=/opt/zlib-1.2.8
[...]# make
[...]# make install
注意:
--with-pcre=/opt/pcre-8.38 指的是pcre-8.38 的源码路径。
--with-zlib=/opt/zlib-1.2.8 指的是zlib-1.2.8 的源码路径。
验证是否安装成功:
[...]# cd /usr/local/nginx/
[...]# cd sbin/
[...]# ./nginx
[...]# netstat -ano|grep 80
[...]# ./nginx -s reload
如果在浏览器中输入本机IP或者localhost能返回 Welcome to nginx!
则表示 Nginx 已经安装并运行成功。