1
0

xcache.sh 2.3 KB

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