echo -e "\033[31m====================注意====================\033[0m" echo "#安装包放在/data/soft/下" echo "#安装路径在/data/app/nginx/下" mkdir -p /data/app mkdir -p /data/soft useradd -M -s /sbin/nologin nginx sleep 2 echo "安装nginx所需插件......" yum -y install pcre pcre-devel openssl openssl-devel gcc gcc-c++ echo "检查是否有wget命令,并通过wget下载nginx包到/data/soft/" if [ `rpm -qa | grep wget | wc -l` -eq 1 ];then read -p "请输入需要下载的版本号(x.x.x格式):" version cd /data/soft/ wget http://nginx.org/download/nginx-${version}.tar.gz else yum -y install wget read -p "请输入需要下载的版本号(x.x.x格式):" version cd /data/soft/ wget http://nginx.org/download/nginx-${version}.tar.gz fi tar xvf nginx-${version}.tar.gz cd nginx-${version} ./configure --user=nginx --group=nginx --prefix=/data/app/nginx --with-http_v2_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-stream && make && make installcat <<EOF > /etc/profile.d/nginx.shnginx_home=/data/app/nginxPATH=$nginx_home/bin:$PATHexport PATHEOFsource /etc/profile
nginx
来源:https://www.cnblogs.com/jameslove/p/11338798.html