!/bin/bash
--------------------------------------------------------
Function: Install nginx for CentOS7
Date: 2019-12-2
Author: Ma Ning
--------------------------------------------------------
Print debug information
NGINX_VER="NGINX_SOFT| sed 's/.tar.*//g'`
NGINX_YUM="yum install -y"
NGINX_ARG="--prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module"
userdel -r nginx
if [ 0 1.2.3|1.12.2}\033[0m"
fi
Installing dependencies
echo "正在安装环境,请稍后!!!"
NGINX_YUM perl perl-devel pcre pcre-devel openssl openssl-devel &>/dev/null
echo "环境已经安装,正在下载nginx"
Downloading
wget -c NGINX_SOFT
cd $NGINX_SRC
Creating user and group
groupadd -g 110 nginx
useradd -u 990 -g 110 -s /sbin/nologin -M nginx
Starting install nginx
./configure $NGINX_ARG
Compile nginx
make && make install
if [ $? -eq 0 ];then
echo "安装成功,正在启动,请稍后!!!"
else
echo "安装失败,请检查!!!"
fi
Starting Nginx
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginxctl
nginxctl
if [ $? -eq 0 ];then
echo "nginx启动成功"
else
echo "启动失败"
fi
Show nginx status
ps -ef |grep nginx
netstat -tnlp |grep nginx
网友评论