#!/bin/bash
#--------------------------------------------------------
# Function: Install nginx for CentOS7
# Date: 2017-10-06
# Author: Jason Wang
#--------------------------------------------------------
DOWNPATH=
"/root/download"
[ ! -d
$DOWNPATH ]&&{
mkdir
$DOWNPATH
}
#Print debug information
function
Debug(){
echo
""
echo
"\033[37m[$(date)]\033[32m ::::::::::>>>>>-----------------<<<<<::::::::::\033[0m"
echo
"\033[37m[$(date)]\033[31m "
$1
"\033[0m"
echo
""
}
#Installing dependencies
yum install -y wget gcc gcc-c++ autoconf automake cmake libtool make
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel
#Creating user and group
#useradd -s /sbin/nologin -M www
groupadd www
useradd -g www www
usermod -s /sbin/nologin www
#Downloading
cd
$DOWNPATH
[ ! -f
${DOWNPATH}/nginx-1.13.8.tar.gz ]&&{
Debug
"Starting download nginx..."
wget http://nginx.org/download/nginx-1.13.8.tar.gz
}
if [
$? -gt 1 ]
then
Debug
"Nginx Installer: download nginx-1.13.8.tar.gz error...."
exit 404
fi
#Starting install nginx
[ ! -d
${DOWNPATH}/nginx-1.13.8 ]&&{
tar -zxvf nginx-1.13.8.tar.gz
}
if [
$? -gt 1 ]
then
Debug
"Nginx Installer: tar nginx-1.13.8.tar.gz error...."
exit 405
fi
cd
${DOWNPATH}/nginx-1.13.8
#Compile nginx
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module
#make
make && make install
#Starting Nginx
/usr/local/nginx/sbin/nginx
#Show nginx status
ps -aux|grep nginx