zendopcache.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. make clean
  16. $php_install_dir/bin/phpize
  17. ./configure --with-php-config=$php_install_dir/bin/php-config
  18. make -j ${THREAD} && make install
  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. popd
  35. rm -rf zendopcache-$zendopcache_version
  36. [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
  37. else
  38. echo "${CFAILURE}PHP OPcache module install failed, Please contact the author! ${CEND}"
  39. fi
  40. popd
  41. }