eaccelerator.sh 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. Install_eAccelerator() {
  11. pushd ${oneinstack_dir}/src > /dev/null
  12. PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
  13. PHP_main_ver=${PHP_detail_ver%.*}
  14. phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
  15. case "${PHP_main_ver}" in
  16. 5.3)
  17. tar jxf eaccelerator-${eaccelerator_ver}.tar.bz2
  18. pushd eaccelerator-${eaccelerator_ver}
  19. ;;
  20. 5.4)
  21. /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz
  22. tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
  23. pushd eaccelerator-eaccelerator-42067ac
  24. ;;
  25. *)
  26. echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"
  27. kill -9 $$
  28. esac
  29. ${php_install_dir}/bin/phpize
  30. ./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config
  31. make -j ${THREAD} && make install
  32. popd
  33. if [ -f "${phpExtensionDir}/eaccelerator.so" ]; then
  34. mkdir /var/eaccelerator_cache;chown -R ${run_user}.${run_user} /var/eaccelerator_cache
  35. cat > ${php_install_dir}/etc/php.d/02-eaccelerator.ini << EOF
  36. [eaccelerator]
  37. zend_extension=${phpExtensionDir}/eaccelerator.so
  38. eaccelerator.shm_size=64
  39. eaccelerator.cache_dir=/var/eaccelerator_cache
  40. eaccelerator.enable=1
  41. eaccelerator.optimizer=1
  42. eaccelerator.check_mtime=1
  43. eaccelerator.debug=0
  44. eaccelerator.filter=
  45. eaccelerator.shm_max=0
  46. eaccelerator.shm_ttl=0
  47. eaccelerator.shm_prune_period=0
  48. eaccelerator.shm_only=0
  49. eaccelerator.compress=0
  50. eaccelerator.compress_level=9
  51. eaccelerator.keys=disk_only
  52. eaccelerator.sessions=disk_only
  53. eaccelerator.content=disk_only
  54. EOF
  55. echo "${CSUCCESS}Accelerator module installed successfully! ${CEND}"
  56. [ -z "$(grep 'kernel.shmmax = 67108864' /etc/sysctl.conf)" ] && echo "kernel.shmmax = 67108864" >> /etc/sysctl.conf
  57. sysctl -p
  58. rm -rf eaccelerator-${eaccelerator_ver} eaccelerator-eaccelerator-42067ac
  59. else
  60. echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}"
  61. fi
  62. popd
  63. }