安裝環境:Centos7.3
nginx版本:nginx-1.18.0
用法:
1)將安裝包(nginx-1.18.0.tar.gz)和指令碼(nginx_install.sh)上傳至伺服器
2)執行指令碼:sh nginx_install.sh
廢話不多說,直接上指令碼:vim nginx_install.sh
#!/bin/bash
###By Luis
yum -y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl
yum -y install openssl-devel
ng_tgz=`find / -name "nginx-1.18.0.tar.gz"`
install_dir=`basename ${ng_tgz} .tar.gz`
if [ ! -d /data/software ];then
mkdir -p /data/software
fi
if [ ! -d /data/temp ];then
mkdir -p /data/temp
fi
tar -xf ${ng_tgz} -C /data/temp/
cd /data/temp/${install_dir}
./configure --prefix=/data/software/nginx --with-http_stub_status_module
make && make install
ln -sv /data/software/nginx/sbin/nginx /usr/bin/nginx