Shell

Nginx自动安装脚本

#!/bin/bash
#Date 2018/3/7
if [ "$USER" != "root" ];then
echo "You must be root to run this script" 
exit 1
fi
echo "###############################################"
echo "#         Auto install nginx                 ##" 
echo "#         Press Ctrl+C to cancel             ##"
echo "#         Any key to contnue                 ##"
echo "###############################################"
echo "(0)Install nginx1.10.3"
echo "(1)Install nginx1.12.2"
echo "(2)Install nginx1.13.9"
echo "(3)Exit"
read -p "Please input your choice:" NUM
case $NUM in
0)
URL="https://nginx.org/download/nginx-1.10.3.tar.gz"
VER=nginx-1.10.3
;;
1)
URL="https://nginx.org/download/nginx-1.12.2.tar.gz"
VER=nginx-1.12.2
;;
2)
URL="https://nginx.org/download/nginx-1.13.9.tar.gz"
VER=nginx-1.13.9
;;
3)
echo -e "\033[41;37m You choice cancel! \033[0m" && exit 0
;;
*)
echo -e "\033[41;37m Input Error! Place input{0|1|2|3} \033[0m" && exit 1
;;
esac
echo -e "\033[32m You choice install $VER.Install\033[0m"
echo -e "\033[5m Press any key to start install $VER... \033[0m"
yum  groupinstall  "Development Tools"   "Server Platform Development"    -y
yum -y install openssl-devel  pcre-devel   zlib-devel
wget -P /tmp  --no-check-certificate  $URL
useradd -r nginx
tar -zxvf /tmp/${VER}.tar.gz;cd $VER
function install(){
./configure --prefix=/usr/local/nginx   \
            --conf-path=/etc/nginx/nginx.conf   \
            --user=nginx   \
            --group=nginx    \
            --error-log-path=/var/log/nginx/error.log   \
            --http-log-path=/var/log/nginx/access.log   \
            --pid-path=/var/run/nginx/nginx.pid   \
            --lock-path=/var/lock/nginx.lock    \
            --with-http_ssl_module    \
            --with-http_gzip_static_module   \
            --with-debug   \
            --with-http_stub_status_module
make &&  make install && /usr/local/nginx/sbin/nginx
};install;[ $? -ne 0 ] &&  exit 1
status=`curl -I   -s  http://127.0.0.1 | awk 'NR==1{print $2}'`
if  [ $status == 200 ];then
      echo -e "\033[31m Nginx Installation success!!! \033[0m"
fi
echo "
安装目录--/usr/local/nginx
配置文件--/etc/nginx/nginx.conf
错误日志--/var/log/nginx/error.log
访问日志--/var/log/nginx/access.log
Pid文件--/var/run/nginx/nginx.pid
锁文件--/var/lock/nginx.lock ">>/root/Nginx.log

 

(0)

本文由 樱花博客 作者:樱花 发表,转载请注明来源!

关键词:

热评文章

评论:

2 条评论,访客:1 条,博主:1 条
  1. Honest1y
    Honest1y发布于: 

    大佬,You choice channel 是什么意思,你选择香奈儿吗?
    echo -e “\033[5m Press any key to start install $VER… \033[0m” 这块不能停下来按任意键继续

发表评论