pecl_pgsql.sh 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_pecl_pgsql() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. pushd ${oneinstack_dir}/src > /dev/null
  13. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  14. PHP_detail_ver=$(${php_install_dir}/bin/php-config --version)
  15. tar xzf php-${PHP_detail_ver}.tar.gz
  16. pushd php-${PHP_detail_ver}/ext/pgsql > /dev/null
  17. ${php_install_dir}/bin/phpize
  18. ./configure --with-pgsql=${pgsql_install_dir} --with-php-config=${php_install_dir}/bin/php-config
  19. make -j ${THREAD} && make install
  20. popd > /dev/null
  21. pushd php-${PHP_detail_ver}/ext/pdo_pgsql > /dev/null
  22. ${php_install_dir}/bin/phpize
  23. ./configure --with-pdo-pgsql=${pgsql_install_dir} --with-php-config=${php_install_dir}/bin/php-config
  24. make -j ${THREAD} && make install
  25. popd > /dev/null
  26. if [ -f "${phpExtensionDir}/pgsql.so" -a -f "${phpExtensionDir}/pdo_pgsql.so" ]; then
  27. echo 'extension=pgsql.so' > ${php_install_dir}/etc/php.d/07-pgsql.ini
  28. echo 'extension=pdo_pgsql.so' >> ${php_install_dir}/etc/php.d/07-pgsql.ini
  29. echo "${CSUCCESS}PHP pgsql module installed successfully! ${CEND}"
  30. rm -rf php-${PHP_detail_ver}
  31. else
  32. echo "${CFAILURE}PHP pgsql module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  33. fi
  34. popd > /dev/null
  35. fi
  36. }
  37. Uninstall_pecl_pgsql() {
  38. if [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ]; then
  39. rm -f ${php_install_dir}/etc/php.d/07-pgsql.ini
  40. echo; echo "${CMSG}PHP pgsql module uninstall completed${CEND}"
  41. else
  42. echo; echo "${CWARNING}PHP pgsql module does not exist! ${CEND}"
  43. fi
  44. }