#!/bin/bash

yum install -y gcc gcc-c++ nginx  php php-fpm  wget

mkdir /opt/web

cd /opt/web
wget -O IPTablesConfig.php  http://47.90.101.26/linux/sh/node_install/IPTablesConfig.php
wget -O index.php http://47.90.101.26/linux/sh/node_install/index.php
wget -O nginx.conf http://47.90.101.26/linux/sh/node_install/nginx.conf
wget -O php-fpm http://47.90.101.26/linux/sh/node_install/php-fpm
wget -O init_iptables.sh http://47.90.101.26/linux/sh/node_install/init_iptables.sh
chmod +x php-fpm
chmod +x init_iptables.sh
./init_iptables.sh

rm -f /etc/nginx/conf.d/default.conf
cp -f php-fpm  /etc/init.d/
cp -f nginx.conf /etc/nginx/conf.d/ssl.conf

sed -i 's/user = apache/user = root/g' /etc/php-fpm.d/www.conf
sed -i 's/group = apache/group = root/g' /etc/php-fpm.d/www.conf

boot_status=`cat /etc/rc.d/rc.local|grep init_iptables.sh|grep -v grep |wc -l`

if [ $boot_status == 0 ];then
echo "/opt/web/init_iptables.sh" >>/etc/rc.d/rc.local
fi

chkconfig --add nginx
chkconfig --level 345 nginx on

chkconfig --add php-fpm
chkconfig --level 345 php-fpm on

/etc/init.d/php-fpm start
/etc/init.d/nginx start


