pecl_fileinfo.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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_fileinfo() {
  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. src_url=https://secure.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
  16. tar xzf php-${PHP_detail_ver}.tar.gz
  17. pushd php-${PHP_detail_ver}/ext/fileinfo > /dev/null
  18. ${php_install_dir}/bin/phpize
  19. ./configure --with-php-config=${php_install_dir}/bin/php-config
  20. sed -i 's@^CFLAGS =.*@CFLAGS = -std=c99 -g@' Makefile
  21. make -j ${THREAD} && make install
  22. popd > /dev/null
  23. if [ -f "${phpExtensionDir}/fileinfo.so" ]; then
  24. echo 'extension=fileinfo.so' > ${php_install_dir}/etc/php.d/04-fileinfo.ini
  25. echo "${CSUCCESS}PHP fileinfo module installed successfully! ${CEND}"
  26. rm -rf php-${PHP_detail_ver}
  27. else
  28. echo "${CFAILURE}PHP fileinfo module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  29. fi
  30. popd > /dev/null
  31. fi
  32. }
  33. Uninstall_pecl_fileinfo() {
  34. if [ -e "${php_install_dir}/etc/php.d/04-fileinfo.ini" ]; then
  35. rm -f ${php_install_dir}/etc/php.d/04-fileinfo.ini
  36. echo; echo "${CMSG}PHP fileinfo module uninstall completed${CEND}"
  37. else
  38. echo; echo "${CWARNING}PHP fileinfo module does not exist! ${CEND}"
  39. fi
  40. }