#!/bin/bash
###################################
#fuction  zabbix-server envirorment 
#created by AL  2018/05/01
####################################

install_path=`pwd`

###lib install
yum install -y gcc gcc-c++  ncurses-devel  curl-devel  libxpm-devel cmake libxml2 libxml2-devel net-snmp-devel libxPm wget libxPm-devel  libXpm-devel  libXpm

## create user and group

groupadd www -g 504
useradd -s /sbin/nologin -M www -u 504 -g 504


###initalize
cp -f  ${install_path}/conf/ld.so.conf  /etc/ld.so.conf

ldconfig


##install zlib1.2.8
cd ${install_path}/files
tar zxf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make && make install




###configure modules
tar zxf ${install_path}/files/modules.tar.gz -C /opt/

###configure php

cp  -f ${install_path}/bin/php-fpm  /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
/sbin/chkconfig --add php-fpm
/sbin/chkconfig --level 345 php-fpm on
tar zxf ${install_path}/files/php.tar.gz -C /opt/
service php-fpm start

###configure nginx
mkdir -p /opt/web/php
cp  -f ${install_path}/bin/nginx  /etc/init.d/nginx

chmod +x /etc/init.d/nginx
/sbin/chkconfig --add nginx
/sbin/chkconfig --level 345 nginx on
tar zxf ${install_path}/files/nginx.tar.gz -C /opt/

service nginx start


if [ $? == 0 ];then
echo "##################"  
echo -e "\033[40;32m install success \033[0m"
echo "###################"

  
 else 
  echo "##############"
 echo -e "\033[40;31m error \033[0m"
 echo "############" 
 fi




















