#!/bin/bash
#具体版本号
PHP_V=7.4.2
TMP_DIR=/tmp
INSTALL_DIR=/usr/local

function install_php() {

    cd $TMP_DIR
    yum -y install gcc gcc-c++ make zlib zlib-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 krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
    wget -c http://mirrors.sohu.com/php/php-${PHP_V}.tar.bz2 &&
    tar -jxvf php-${PHP_V}.tar.bz2 && cd php-${PHP_V} &&
    mv php-${PHP_V} $INSTALL_DIR/php
    cd $INSTALL_DIR/php;
    ./configure --prefix=$INSTALL_DIR/php --with-config-file-path=$INSTALL_DIR/php/etc
    sleep 1s;
    if [ $? -eq 0 ];then
    make ZEND_EXTRA_LIBS="-liconv" &&make install
    echo -e " 33[32m PHP服务安装成功! 33[0m"
    else
    echo -e " 33[32m PHP服务安装失败,请检测配置文件! 33[0m"
    exit
    fi
}
install_php
03-05 20:07