apcu.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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_APCU() {
  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. if [ "`${php_install_dir}/bin/php-config --version | awk -F. '{print $1}'`" == '5' ]; then
  15. tar xzf apcu-${apcu_oldver}.tgz
  16. pushd apcu-${apcu_oldver} > /dev/null
  17. else
  18. tar xzf apcu-${apcu_ver}.tgz
  19. pushd apcu-${apcu_ver} > /dev/null
  20. fi
  21. ${php_install_dir}/bin/phpize
  22. ./configure --with-php-config=${php_install_dir}/bin/php-config
  23. make -j ${THREAD} && make install
  24. if [ -f "${phpExtensionDir}/apcu.so" ]; then
  25. cat > ${php_install_dir}/etc/php.d/02-apcu.ini << EOF
  26. [apcu]
  27. extension=apcu.so
  28. apc.enabled=1
  29. apc.shm_size=32M
  30. apc.ttl=7200
  31. apc.enable_cli=1
  32. EOF
  33. /bin/cp apc.php ${wwwroot_dir}/default
  34. popd > /dev/null
  35. echo "${CSUCCESS}PHP apcu module installed successfully! ${CEND}"
  36. rm -rf apcu-${apcu_ver} apcu-${apcu_oldver} package.xml
  37. else
  38. echo "${CFAILURE}PHP apcu module install failed, Please contact the author! ${CEND}" && grep -Ew 'NAME|ID|ID_LIKE|VERSION_ID|PRETTY_NAME' /etc/os-release
  39. fi
  40. popd > /dev/null
  41. fi
  42. }
  43. Uninstall_APCU() {
  44. if [ -e "${php_install_dir}/etc/php.d/02-apcu.ini" ]; then
  45. rm -rf ${php_install_dir}/etc/php.d/02-apcu.ini ${wwwroot_dir}/default/apc.php
  46. echo; echo "${CMSG}PHP apcu module uninstall completed${CEND}"
  47. else
  48. echo; echo "${CWARNING}PHP apcu module does not exist! ${CEND}"
  49. fi
  50. }