centos7 安装 php5.6版本
参考安装文档: 
https://blog.csdn.net/weixin_33862993/article/details/91938824
https://www.cnblogs.com/sharktech/p/14194728.html
1. 下载php源码安装包
   wget https://www.php.net/distributions/php-5.6.40.tar.gz
2. 安装常用的依赖
    yum -y install gcc gcc-c++ automake autoconf make \
    libtool systemd-devel glibc glibc-devel \
    mcrypt libmcrypt libmcrypt-devel mhash mhash-devel libxslt libxslt-devel \
    libjpeg libjpeg-devel openjpeg-devel libpng libpng-devel \
    libcurl libcurl-devel gmp gmp-devel libicu libicu-devel \
    freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel \
    glib2 glib2-devel bzip2 bzip2-devel curl curl-devel \
    readline readline-devel ncurses ncurses-devel \
    e2fsprogs e2fsprogs-devel openssl openssl-devel 
3. 添加php-fpm的用户,或者用nobody用户
    chattr -i /etc/group /etc/gshadow /etc/passwd /etc/shadow
    #创建群组并创建一个用户,不允许登陆和不创主目录
    groupadd php-fpm && useradd -s /sbin/nologin -g php-fpm -M php-fpm 
    3. 进入php源码目录,编译安装cd php-5.6.40
    ./configure \
     --prefix=/usr/local/services/php5.6 \
     --with-config-file-path=/usr/local/services/php5.6/etc \
     --with-config-file-scan-dir=/usr/local/services/php5.6/etc/php.d \
     --with-fpm-user=nobody \
     --with-fpm-group=nobody \
     --with-mysql-sock \
     --with-mysql \
     --with-mysqli=mysqlnd \
     --with-pdo-mysql=mysqlnd \
     --with-pdo-sqlite \
     --with-fpm-systemd \
     --with-pcre-regex \
     --with-sqlite3 \
     --with-cdb \
     --with-kerberos \
     --with-gmp \
     --with-mhash \
     --with-libmbfl \
     --with-onig \
     --with-readline \
     --with-pear \
     --with-xmlrpc \
     --with-xsl \
     --with-gettext \
     --with-openssl \
     --with-zlib \
     --with-bz2 \
     --with-gd \
     --with-curl \
     --with-mcrypt \
     --with-pear \
     --with-libxml-dir \
     --with-freetype-dir \
     --with-jpeg-dir \
     --with-png-dir \
     --with-pcre-dir \
     --with-iconv-dir \
     --enable-fpm \
     --enable-pdo \
     --enable-bcmath \
     --enable-mysqlnd \
     --enable-xmlreader \
     --enable-xmlwriter \
     --enable-calendar \
     --enable-shmop \
     --enable-static \
     --enable-shared \
     --enable-soap \
     --enable-xml \
     --enable-json \
     --enable-mbstring \
     --enable-mbregex \
     --enable-mbregex-backtrack \
     --enable-dom \
     --enable-exif \
     --enable-fileinfo \
     --enable-filter \
     --enable-inline-optimization \
     --enable-pcntl \
     --enable-sockets \
     --enable-ftp \
     --enable-intl \
     --enable-zip \
     --enable-session \
     --enable-simplexml \
     --enable-sysvmsg \
     --enable-sysvsem \
     --enable-sysvshm \
     --enable-wddx \
     --enable-mysqlnd-compression-support \
     --enable-embedded-mysqli \
     --enable-gd-native-ttf \
     --enable-gd-jis-conv \
     --enable-tokenizer \
     --enable-opcache \
     --disable-phpdbg-debug \
     --disable-debug

    make -j 16 && make install 
    或者
    make ZEND_EXTRA_LIBS='-liconv' -j 16 && make install
4. 安装扩展库
    yum -y install libevent libevent-devel \
        libmemcached libmemcached-devel \
        cyrus-sasl cyrus-sasl-devel \
        zlib zlib-devel \
        fastlz.x86_64 fastlz-devel.x86_64
    a. 安装redis扩展
        wget https://pecl.php.net/get/redis-4.3.0.tgz
        tar xvf redis-4.3.0.tgz
        cd redis-4.3.0
        /usr/local/services/php5.6/bin/phpize
        ./configure --with-php-config=/usr/local/services/php5.6/bin/php-config
        make -j 16 && make install

5. 处理配置文件
    cp php.ini-production /usr/local/services/php5.6/etc/php.ini
    cd sapi/fpm;
    cp php-fpm.service /usr/lib/systemd/system/php5-fpm.service
6. 修改配置文件
    mkdir -p /usr/local/services/php5.6/etc/php.d
    添加以下配置
    cat > /usr/local/services/php5.6/etc/php.d/ext-opcache.ini << EOF
[opcache]
;zend_extension=opcache.so
;opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=$Memory_limit
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=100000
opcache.max_wasted_percentage=5
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=60
opcache.save_comments=0
opcache.fast_shutdown=1
opcache.consistency_checks=0
;opcache.optimization_level=0
EOF
    cat > /usr/local/services/php5.6/etc/php.d/ext-redis.ini << EOF
[redis]
extension=redis.so
EOF