Nginx 离线安装:
一、安装包下载
Nginx安装包:http://nginx.org/en/download.html
openssl安装包:https://www.openssl.org/source/
pcre安装包:https://ftp.pcre.org/pub/pcre/
我的版本是:nginx-1.14.2.tar.gz,pcre-8.37.tar.gz,openssl.1.1.1a.tar.gz
二.解压Nginx
###nginx安装
借助xftp6工具将安装包上传到linux系统中,我是上传到/home/src
cd /home/src
tar -zxvf nginx-1.14.2.tar.gz
cd nginx-1.14.2/
./configure
--prefix=/home/nginx(不指定在/usr/local/nginx)
make &&make install
可能报错缺少openssl或者pcre资源库,由于nginx依赖openssl(安全库)和pcre(正则表达式资源库)
###openssl安装
cd /home/src
tar -zxvfopenssl.1.1.1.tar.gz
cd openssl.1.1.1a/
./config--prefix=/home/openssl
./config -t
make open
make install
###pcre安装
cd /home/src
tar -zxvfpcre-8.37.tar.gz
cd pcre-8.37/
./configure--prefix=/home/pcre
make &&make install
三、启动
cd /home/nginx/sbin
启动:./nginx 或者 ./nginx -c /home/nginx/conf/nginx.conf
注意若缺少依赖库
ldd $(which
/usr/local/nginx/sbin/nginx)
linux-gate.so.1=> (0x0071b000)
libpthread.so.0=> /lib/libpthread.so.0 (0×00498000)
libcrypt.so.1=> /lib/libcrypt.so.1 (0×00986000)
libpcre.so.1=> not found //问题在这
libcrypto.so.6=> /lib/libcrypto.so.6 (0×00196000)
libz.so.1=> /lib/libz.so.1 (0×00610000)
libc.so.6=> /lib/libc.so.6 (0x002d7000)
/lib/ld-linux.so.2(0x006a8000)
libdl.so.2 => /lib/libdl.so.2 (0x008c3000)
查看少什么找到添加软连接过去
ln -s/usr/local/lib/libpcre.so.0.0.1 /lib/libpcre.so.1 //具体的路径根据自己libpcre.so.0.0.1的位置决定
错误1:
./configure: error: the HTTP rewritemodule requires the PCRE library.
You can eitherdisable the module by using --without-http_rewrite_module
option, or installthe PCRE library into the system, or build the PCRE library
statically from thesource with nginx by using --with-pcre= option.
解决办法:yum -y installpcre-devel
错误2:
./configure: error: the HTTP gzipmodule requires the zlib library.
You can eitherdisable the module by using --without-http_gzip_module
option, or install thezlib library into the system, or build the zlib library
statically from thesource with nginx by using --with-zlib= option.
yum install -y zlib-devel
错误4:make not comond
C compiler cc isnot found
安装:
yum -y install gccautomake autoconf libtool make
安装g++:
yum install gccgcc-c++
make
make install