zendopcache.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # Blog: http://blog.linuxeye.com
  4. Install_ZendOPcache()
  5. {
  6. cd $oneinstack_dir/src
  7. . ../functions/download.sh
  8. . ../options.conf
  9. src_url=https://pecl.php.net/get/zendopcache-$zendopcache_version.tgz && Download_src
  10. tar xzf zendopcache-$zendopcache_version.tgz
  11. cd zendopcache-$zendopcache_version
  12. make clean
  13. $php_install_dir/bin/phpize
  14. ./configure --with-php-config=$php_install_dir/bin/php-config
  15. make && make install
  16. Mem=`free -m | awk '/Mem:/{print $2}'`
  17. if [ $Mem -gt 1024 -a $Mem -le 1500 ];then
  18. Memory_limit=192
  19. elif [ $Mem -gt 1500 -a $Mem -le 3500 ];then
  20. Memory_limit=256
  21. elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
  22. Memory_limit=320
  23. elif [ $Mem -gt 4500 ];then
  24. Memory_limit=448
  25. else
  26. Memory_limit=128
  27. fi
  28. if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/opcache.so" ];then
  29. cat >> $php_install_dir/etc/php.ini << EOF
  30. [opcache]
  31. zend_extension="$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/opcache.so"
  32. opcache.memory_consumption=$Memory_limit
  33. opcache.interned_strings_buffer=8
  34. opcache.max_accelerated_files=4000
  35. opcache.revalidate_freq=60
  36. opcache.save_comments=0
  37. opcache.fast_shutdown=1
  38. opcache.enable_cli=1
  39. ;opcache.optimization_level=0
  40. EOF
  41. [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
  42. else
  43. echo -e "\033[31meZend OPcache module install failed, Please contact the author! \033[0m"
  44. fi
  45. cd ..
  46. /bin/rm -rf zendopcache-$zendopcache_version
  47. cd ..
  48. }