php7.4.4 安装shell

#! /bin/bash 可供参考网址:https://www.cnblogs.com/architectforest/p/12433541.html
#基础包
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 libicu-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 openldap-devel sqlite-devel libcurl-devel
yum -y install mysql-devel #该服务器没安装mysql的话

#其它centos7必备
yum install net-tools vim wget -y

##编译安装 php7
php7="false"

cd /home/soft || mkdir /home/soft && cd /home/soft

#先编译安装php7.4的依赖oniguruma
yum install -y autoconf automake libtool
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz
tar -zxvf oniguruma-6.9.4.tar.gz
cd oniguruma-6.9.4/
./autogen.sh && ./configure --prefix=/usr
make && make install


cd /home/soft
tar -xvf php-7.4.4.tar.gz || wget http://cn2.php.net/distributions/php-7.4.4.tar.gz && tar -xvf php-7.4.4.tar.gz

cd php-7.4.4/ && ./configure --prefix=/usr/local/php --sysconfdir=/usr/local/php/etc --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/etc/php.d --with-freetype-dir=/usr/include/freetype2/freetype/ --enable-fpm --enable-mbstring --enable-zip --enable-mysqlnd --with-iconv --with-zlib --enable-xml --with-curl --with-gd --with-openssl --with-mhash --enable-bcmath --enable-sockets --enable-pcntl --with-xmlrpc --enable-zip --enable-soap --enable-opcache --with-pdo-mysql --enable-maintainer-zts --with-jpeg-dir=/usr && make clean && make && make install && php7="true"


if [ ${php7} != "true" ]
then
echo "php7 install not Success." >>/var/log/install-php7.log
exit 1
else
echo "php7 install Success." >>/var/log/install-php7.log
fi

mkdir /usr/local/php/etc/php.d -p
cd /home/soft/php-7.4.4/sapi/fpm
cp init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cp php-fpm.conf /usr/local/php/etc/php-fpm.conf
mkdir /usr/local/php/etc/php-fpm.d -p
cp www.conf /usr/local/php/etc/php-fpm.d/www.conf
cd /home/soft/php-7.4.4
cp php.ini-production /usr/local/php/etc/php.ini
cp /usr/local/php/bin/php /usr/bin/php


cat >/usr/local/php/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"
cd /home/soft
wget -c https://github.com/phpredis/phpredis/archive/develop.zip && unzip develop.zip && cd phpredis-develop/ && /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install && echo "extension=redis.so" >> /usr/local/php/etc/php.d/20.redis.ini && redisextend="true"

if [ ${redisextend} != "true" ]
then
echo "redisextend install not Success." >>/var/log/install-php7.log
exit 2
else
echo "redisextend install Success." >>/var/log/install-php7.log
fi


##igbinary扩展
igbinaryextend="false"
cd /home/soft
wget -c https://github.com/igbinary/igbinary/archive/master.zip && unzip master.zip && cd igbinary-master && /usr/local/php/bin/phpize && ./configure CFLAGS="-O2 -g" --enable-igbinary --with-php-config=/usr/local/php/bin/php-config && make && make install && echo "extension=igbinary.so" >> /usr/local/php/etc/php.d/20.igbinary.ini && igbinaryextend="true"


if [ ${igbinaryextend} != "true" ]
then
echo "igbinaryextend install not Success." >>/var/log/install-php7.log
exit 3
else
echo "igbinaryextend install Success." >>/var/log/install-php7.log
fi

##memcached扩展
memcacheextend="false"
cd /home/soft
##安装libmemcached-devel,本来是yum install -y libmemcached-devel(但安装不了)
mkdir /usr/local/libmemcached
mkdir /usr/local/memcached
##http://blog.joefom.com/archives/58 编译有问题参考处理 将clients/memflush.cc的42行和51行作如下修改:- if (opt_servers == false) + if (!opt_servers)
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz && tar -zxvf libmemcached-1.0.18.tar.gz && cd libmemcached-1.0.18 && ./configure -prefix=/usr/local/libmemcached -with-memcached=/usr/local/memcached && make && make install
cd /home/soft
yum install -y libmemcached && wget https://codeload.github.com/php-memcached-dev/php-memcached/zip/php7 && unzip php7 && cd php-memcached-php7/ && /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached-igbinary && make && make install && echo "extension=memcached.so" >> /usr/local/php/etc/php.d/20.memcached.ini && memcacheextend="true"


if [ ${memcacheextend} != "true" ]
then
echo "memcacheextend install not Success." >>/var/log/install-php7.log
exit 4
else
echo "memcacheextend install Success." >>/var/log/install-php7.log
fi