#! /bin/bash
#基础包
yum install -y bash gcc gcc-c++ glibc make cmake libaio-devel gmp-devel libmcrypt-devel zlib zlib-devel openssh openssl openssl-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel xinetd lrzsz dos2unix postfix libtool
##编译安装 php7
php7="false"
cd /root/soft || mkdir /root/soft && cd /root/soft
wget http://cn2.php.net/distributions/php-7.0.11.tar.gz
tar -xvf php-7.0.11.tar.gz
cd php-7.0.11/ && ./configure --prefix=/usr/local/php7 --sysconfdir=/usr/local/php7/etc --with-config-file-path=/usr/local/php7/etc --with-config-file-scan-dir=/usr/local/php7/etc/php.d --enable-fpm --enable-mbstring --enable-zip --enable-mysqlnd --with-iconv --with-zlib --enable-xml --with-curl --with-gd --with-openssl --with-mhash --enable-sockets --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts && make clean && make && make install && php7="true"
if [ ${php7} != "true" ]
then
echo "php7 install not Success."
exit 1
fi
mkdir /usr/local/php7/etc/php.d -p
cd /root/soft/php-7.0.11/sapi/fpm
cp init.d.php-fpm /etc/init.d/php7-fpm
chmod +x /etc/init.d/php7-fpm
chkconfig --add php7-fpm
chkconfig php7-fpm on
cp php-fpm.conf /usr/local/php7/etc/php-fpm.conf
cp www.conf /usr/local/php7/etc/php-fpm.d/www.conf
cd /root/soft/php-7.0.11
cp php.ini-production /usr/local/php7/etc/php.ini
cat >/usr/local/php7/etc/php.d/10-opcache.ini <<EOFF
zend_extension=opcache.so
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.blacklist_filename=/etc/php.d/opcache*.blacklist
EOFF
##redis 扩展
redisextend="false"
yum install unzip -y
cd /root/soft
wget -c https://github.com/phpredis/phpredis/archive/php7.zip && unzip php7.zip && cd phpredis-php7/ && /usr/local/php7/bin/phpize && ./configure --with-php-config=/usr/local/php7/bin/php-config && make && make install && echo "extension=redis.so" >> /usr/local/php7/etc/php.d/20.redis.ini && redisextend="true"
if [ ${redisextend} != "true" ]
then
echo "redisextend install not Success."
exit 2
fi
##igbinary扩展
igbinaryextend="false"
cd /root/soft
wget -c https://github.com/igbinary/igbinary/archive/master.zip && unzip master.zip && cd igbinary-master && /usr/local/php7/bin/phpize && ./configure CFLAGS="-O2 -g" --enable-igbinary --with-php-config=/usr/local/php7/bin/php-config && make && make install && echo "extension=igbinary.so" >> /usr/local/php7/etc/php.d/20.igbinary.ini && igbinaryextend="true"
if [ ${igbinaryextend} != "true" ]
then
echo "igbinaryextend install not Success."
exit 3
fi
##memcache扩展
memcacheextend="false"
cd /root/soft
yum install -y libmemcached10-devel libmemcached10 && wget https://codeload.github.com/php-memcached-dev/php-memcached/zip/php7 && unzip php7 && cd php-memcached-php7/ && /usr/local/php7/bin/phpize && ./configure --with-php-config=/usr/local/php7/bin/php-config --enable-memcached-igbinary && make && make install && echo "extension=memcached.so" >> /usr/local/php7/etc/php.d/20.memcached.ini && memcacheextend="true"
if [ ${memcacheextend} != "true" ]
then
echo "memcacheextend install not Success."
fi