ZendGuardLoader.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Install_ZendGuardLoader() {
  11. if [ -e "${php_install_dir}/bin/phpize" ]; then
  12. pushd ${oneinstack_dir}/src > /dev/null
  13. PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
  14. PHP_main_ver=${PHP_detail_ver%.*}
  15. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  16. [ -e "${php_install_dir}/bin/phpize" ] && [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
  17. if [ -n "`echo $phpExtensionDir | grep 'non-zts'`" ] && [ "${armplatform}" != 'y' ]; then
  18. case "${PHP_main_ver}" in
  19. 5.6)
  20. tar xzf zend-loader-php5.6-linux-${SYS_BIT_c}.tar.gz
  21. /bin/mv zend-loader-php5.6-linux-${SYS_BIT_c}/ZendGuardLoader.so ${phpExtensionDir}
  22. rm -rf zend-loader-php5.6-linux-${SYS_BIT_c}
  23. ;;
  24. 5.5)
  25. tar xzf zend-loader-php5.5-linux-${SYS_BIT_c}.tar.gz
  26. /bin/mv zend-loader-php5.5-linux-${SYS_BIT_c}/ZendGuardLoader.so ${phpExtensionDir}
  27. rm -rf zend-loader-php5.5-linux-${SYS_BIT_c}
  28. ;;
  29. 5.4)
  30. tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}.tar.gz
  31. /bin/mv ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir}
  32. rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}
  33. ;;
  34. 5.3)
  35. tar xzf ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}.tar.gz
  36. /bin/mv ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir}
  37. rm -rf ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}
  38. ;;
  39. *)
  40. echo "${CWARNING}Your php ${PHP_detail_ver} does not support ZendGuardLoader! ${CEND}";
  41. ;;
  42. esac
  43. if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then
  44. cat > ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini<< EOF
  45. [Zend Guard Loader]
  46. zend_extension=${phpExtensionDir}/ZendGuardLoader.so
  47. zend_loader.enable=1
  48. zend_loader.disable_licensing=0
  49. zend_loader.obfuscation_level_support=3
  50. EOF
  51. echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}"
  52. fi
  53. else
  54. echo "Error! Your Apache's prefork or PHP already enable thread safety! "
  55. fi
  56. popd > /dev/null
  57. fi
  58. }
  59. Uninstall_ZendGuardLoader() {
  60. if [ -e "${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini" ]; then
  61. rm -f ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini
  62. echo; echo "${CMSG}PHP ZendGuardLoader module uninstall completed${CEND}"
  63. else
  64. echo; echo "${CWARNING}PHP ZendGuardLoader module does not exist! ${CEND}"
  65. fi
  66. }