xcache.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_XCache() {
  11. pushd ${oneinstack_dir}/src
  12. phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
  13. tar xzf xcache-${xcache_version}.tar.gz
  14. pushd xcache-${xcache_version}
  15. ${php_install_dir}/bin/phpize
  16. ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=${php_install_dir}/bin/php-config
  17. make -j ${THREAD} && make install
  18. popd
  19. if [ -f "${phpExtensionDir}/xcache.so" ]; then
  20. /bin/cp -R htdocs ${wwwroot_dir}/default/xcache
  21. chown -R ${run_user}.$run_user ${wwwroot_dir}/default/xcache
  22. touch /tmp/xcache;chown ${run_user}.${run_user} /tmp/xcache
  23. cat > ${php_install_dir}/etc/php.d/ext-xcache.ini << EOF
  24. [xcache-common]
  25. extension=xcache.so
  26. [xcache.admin]
  27. xcache.admin.enable_auth=On
  28. xcache.admin.user=admin
  29. xcache.admin.pass="$xcache_admin_md5_pass"
  30. [xcache]
  31. xcache.size=$(expr $Memory_limit / 2)M
  32. xcache.count=$(expr `cat /proc/cpuinfo | grep -c processor` + 1)
  33. xcache.slots=8K
  34. xcache.ttl=3600
  35. xcache.gc_interval=300
  36. xcache.var_size=4M
  37. xcache.var_count=$(expr `cat /proc/cpuinfo | grep -c processor` + 1)
  38. xcache.var_slots=8K
  39. xcache.var_ttl=0
  40. xcache.var_maxttl=0
  41. xcache.var_gc_interval=300
  42. xcache.test=Off
  43. xcache.readonly_protection=Off
  44. xcache.shm_scheme=mmap
  45. xcache.mmap_path=/tmp/xcache
  46. xcache.coredump_directory=
  47. xcache.cacher=On
  48. xcache.stat=On
  49. xcache.optimizer=Off
  50. [xcache.coverager]
  51. ; enabling this feature will impact performance
  52. ; enable only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value"
  53. ; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions
  54. xcache.coverager = Off
  55. xcache.coverager_autostart = On
  56. xcache.coveragedump_directory = ""
  57. EOF
  58. echo "${CSUCCESS}Xcache module installed successfully! ${CEND}"
  59. rm -rf xcache-${xcache_version}
  60. else
  61. echo "${CFAILURE}Xcache module install failed, Please contact the author! ${CEND}"
  62. fi
  63. popd
  64. }