安装文件下载地址:
- nginx:http://nginx.org/download/nginx-1.12.2.tar.gz
- openssl:https://www.openssl.org/source/openssl-1.0.2o.tar.gz
- zlib:http://zlib.net/zlib-1.2.11.tar.gz
- pcre:https://sourceforge.net/projects/pcre/files/pcre/8.41/pcre-8.41.tar.gz
编译安装
确保安装c++编译环境(gcc -v 检查):
yum install gcc-c++
openssl:
tar zxvf openssl-1.0.2o.tar.gz
cd openssl-1.0.2o
./config
make
make install
pcre:
tar zxvf pcre-8.41.tar.gz
cd pcre-8.41
./configure
make
make install
zlib:
tar zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
nginx:
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure
make
make install
启动nginx:
/usr/local/nginx/sbin/nginx
如果报错:
error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
网上查到说原因是 在RedHat 64位机器上nginx读取的pcre文件为/lib64/libpcre.so.1文件,默认安装pcre时libpcre.so文件安装在/usr/local/lib/目录下,所以输入/opt/nginx/sbin/nginx -V 找不到文件路径!!
解决:
1.首先确定安装了pcre.
2.切换路径: cd /usr/local/lib 执行 ln -s /usr/local/lib/libpcre.so.1 /lib64/
3.root权限下添加软链接 /usr/local/lib/libpcre.so.1 到 /lib64/ : ln -s /usr/local/lib/libpcre.so.1 /lib64/