zendopcache.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. Install_ZendOPcache() {
  11. pushd ${oneinstack_dir}/src
  12. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  13. tar xzf zendopcache-$zendopcache_version.tgz
  14. pushd zendopcache-$zendopcache_version
  15. ${php_install_dir}/bin/phpize
  16. ./configure --with-php-config=${php_install_dir}/bin/php-config
  17. make -j ${THREAD} && make install
  18. popd
  19. if [ -f "${phpExtensionDir}/opcache.so" ]; then
  20. cat > ${php_install_dir}/etc/php.d/ext-opcache.ini << EOF
  21. [opcache]
  22. zend_extension=${phpExtensionDir}/opcache.so
  23. opcache.enable=1
  24. opcache.memory_consumption=$Memory_limit
  25. opcache.interned_strings_buffer=8
  26. opcache.max_accelerated_files=4000
  27. opcache.revalidate_freq=60
  28. opcache.save_comments=0
  29. opcache.fast_shutdown=1
  30. opcache.enable_cli=1
  31. ;opcache.optimization_level=0
  32. EOF
  33. echo "${CSUCCESS}PHP OPcache module installed successfully! ${CEND}"
  34. rm -rf zendopcache-${zendopcache_version}
  35. else
  36. echo "${CFAILURE}PHP OPcache module install failed, Please contact the author! ${CEND}"
  37. fi
  38. popd
  39. }