#!/bin/bash
# install Nginx 1.6.2 + mysql5.5.x + PHP-FPM 5.4.x + Zabbix 2.4.4 automatically.
# Tested on CentOS 6.5
##############################################
# 变量
##############################################
err_echo(){
echo -e "\e[91m[Error]: $1 33[0m"
exit 1
}
info_echo(){
echo -e "\e[92m[Info]: $1 33[0m"
}
warn_echo(){
echo -e "\e[93m[Warning]: $1 33[0m"
}
check_exit(){
if [ $? -ne 0 ]; then
err_echo "$1"
exit1
fi
}
##############################################
# check
##############################################
if [ $EUID -ne 0 ]; then
err_echo "please run this script as root user."
exit 1
fi
if [ "$(awk '{if ( $3 >= 6.0 ) print "CentOS 6.x"}' /etc/redhat-release 2>/dev/null)" != "CentOS 6.x" ];then
err_echo "This script is used for RHEL/CentOS 6.x only."
fi
##############################################
# Useradd deploy nginx程序运行账号
##############################################
info_echo "Useradd deploy"
useradd deploy
##############################################
# yum repo
##############################################
info_echo "配置yum源......"
if [ ! -f LNMP+zabbix.repo ]; then
cat> /etc/yum.repos.d/LNMP+zabbix.repo <<'EOF'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1
[webtatic]
name=Webtatic Repository EL6 - $basearch
#baseurl=http://repo.webtatic.com/yum/el6/$basearch/
mirrorlist=http://mirror.webtatic.com/yum/el6/$basearch/mirrorlist
failovermethod=priority