DevOps

php install script (PHP 자동 설치 스크립트)

IT오이시이 2017. 8. 22. 10:34
728x90

PHP  자동 설치 스크립트 (php install script )

 

 www.php.net에서  최신의  안정 버전의 버전 정보를 확인 합니다.  그리고 아래와 같이 버전 정보를 수정합니다.

간혹 수정된 내용의 히스토리를 기억 하기 위해서 아래와 같이 릴리즈된 날짜도 같이 기입해서 설치한 버전의 이력을 관리 할 수 있도록 합니다.

VER="5.6.19"  #20160325 

아래 소스를 /usr/local/src/websrc 에 만들고 실행 하면 됩니다.

 

/usr/local/src/websrc/install_php.sh





mkdir php_src
cd php_src




# ***************************************
  echo " >> GET PHP-SRC "
# ***************************************


VER="5.4.0"
VER="5.3.13"
VER="5.4.11"  #20130213
VER="5.6.19"  #20160325
VER="7.6.31"  #20170706
VER="7.1.8"   #20170803


rm -rf php-$VER


if [ !  -f php-$VER.tar.bz2 ]
then
    echo " >> PHP Download !! "
    wget http://kr.php.net/get/php-$VER.tar.bz2/from/this/mirror  -O php-$VER.tar.bz2
    tar xvjf php-$VER.tar.bz2
else
    ls -al  php-$VER.tar.bz2
    tar xvjf php-$VER.tar.bz2
fi


## --------------------------------------------------
yum install -y re2c libxml2 libxml2-devel libcurl libcurl-devel libXpm libXpm-devel gd gd-devel pcre pcre-devel net-snmp net-snmp-devel




# ***************************************
  echo " >> Configure PHP "
# ***************************************


cd php-${VER}
make clean


PLATFORM=`uname -i`
lib_src="/usr/lib"


  if [ $PLATFORM = "x86_64" ]
  then
      lib_64=" --with-libdir=lib64 "
      lib_src="/usr/lib64"
      export LDFLAGS="-L/usr/lib64 -L/usr/lib"
  fi
  if [ -d "/usr/local/apache2" ]
  then
      config_apache=" --with-apxs2=/usr/local/apache2/bin/apxs ";
  fi


  if [ -f ~oracle/.bashrc ]
  then
     config_oracle=" --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib  --enable-sigchild --enable-inline-optimization "
     config_oracle_pdo=" --with-pdo-oci=instantclient,/usr,11.2 "
  fi


  oracle_client_chk=`find /usr/includes -name "oci.h" 2>/dev/null | wc -l`
  if [ $oracle_client_chk -eq 1 ]
  then
     config_oracle=" --with-oci8=instantclient,/usr/lib/oracle/11.2/client64/lib  --enable-sigchild --enable-inline-optimization "
     config_oracle_pdo=" --with-pdo-oci=instantclient,/usr,11.2 "
  fi


  MYSQL_CONFIG="/usr/bin/mysql_config"


  if [  -e "$MYSQL_CONFIG" ]
  then
    MYSQL_LIB_DIR=`/usr/bin/mysql_config --variable=pkglibdir`;


    if [ ! -L $MYSQL_LIB_DIR/libmysqlclient.so ]
    then
        MYSQL_LD_CLNT_SO=`find $MYSQL_LIB_DIR -name "libmysqlclient.so.*"  |sort|tail -1 `
        MYSQL_LD_CLNT_R=`find $MYSQL_LIB_DIR -name "libmysqlclient_r.so.*" |sort|tail -1 `
        if [ -f "$MYSQL_LD_CLNT_SO" ]
        then
              ln -s $MYSQL_LD_CLNT_SO  ${MYSQL_LIB_DIR}/libmysqlclient.so
              ln -s $MYSQL_LD_CLNT_R  ${MYSQL_LIB_DIR}/libmysqlclient_r.so
        fi
        echo " SHARED Obj MAKE LINK : ln -s $MYSQL_LD_CLNT_SO  ${MYSQL_LIB_DIR}/libmysqlclient.so ";
        echo " SHARED Obj MAKE LINK : ln -s $MYSQL_LD_CLNT_R  ${MYSQL_LIB_DIR}/libmysqlclient_r.so ";
    fi
    config_mysql=" --with-mysql=mysqlnd --with-mysqli=mysqlnd ";
    config_mysql_pdo=" --with-pdo-mysql=mysqlnd ";
  fi


  if [ -d "/usr/pgsql" ]
  then
      config_pgsql="  --with-pgsql=/usr/pgsql  ";
      #config_pdo_pgsql="  --with-pdo-pgsql=/usr/pgsql ";
  fi


./configure --prefix=/usr/local --exec-prefix=/usr/local \
             $config_apache $lib_64  --enable-fpm \
            --enable-sockets --enable-zip --enable-shared --enable-static \
            --enable-mbstring --enable-mbregex --enable-bcmath --enable-ftp --disable-debug \
            --with-config-file-path=/usr/local/lib --with-curl=/usr \
            --with-openssl --with-iconv \
            --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-freetype-dir=/usr --enable-gd-native-ttf \
            $config_oracle $config_oracle_pdo \
            $config_mysql $config_mysql_pdo \
            $config_pgsql $config_pgsqll_pdo \
            --with-snmp=/usr --with-openssl-dir=/usr \
            --enable-roxen-zts
#            --with-pdo-oci=instantclient,/usr/lib/oracle/11.2/client64/lib,11.2 \




tail -50 config.log


make && make install > install_php_fpm.log &

 

728x90
반응형