cd /usr/local/src
wget "http://nginx.org/download/nginx-1.12.1.tar.gz"
tar zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1
./configure --prefix=/usr/local/nginx
出错提示checking for PCRE library ... not found
checking for PCRE library in /usr/local/ ... not found
checking for PCRE library in /usr/include/pcre/ ... not found
checking for PCRE library in /usr/pkg/ ... not found
checking for PCRE library in /opt/local/ ... not found
./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= option.
nginx的url重写模块依赖PCRE库,安装pcre库cd /usr/local/src
wget "https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz"
tar zxvf pcre-8.41.tar.gz
cd pcre-8.41
./configure --prefix=/usr/local/pcre
提示错误configure: error: You need a C++ compiler for C++ support.
需要c++编译器,安装c++编译器yum install -y gcc gcc-c++ gdb autoconf automake
继续安装pcre库./configure --prefix=/usr/local/pcre
make
make install
安装pcre库成功,继续安装nginx./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2l
make
make install
安装成功
configure里pcre zlib openssl都不需要安装,指定源文件目录即可。
完整的安装脚本# install compiler
yum install -y gcc gcc-c++ gdb autoconf automake
# download soft
cd /usr/local/src
wget "http://nginx.org/download/nginx-1.12.1.tar.gz"
wget "https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz"
wget "https://www.openssl.org/source/openssl-1.0.2l.tar.gz"
wget "http://www.zlib.net/zlib-1.2.11.tar.gz"
tar zxvf pcre-8.41.tar.gz
tar zxvf nginx-1.12.1.tar.gz
tar zxvf openssl-1.0.2l.tar.gz
tar zxvf zlib-1.2.11.tar.gz
# install nginx
cd /usr/local/src/nginx-1.12.1
./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2l
make
make install