xcache.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # Blog: http://blog.linuxeye.com
  4. Install_XCache()
  5. {
  6. cd $oneinstack_dir/src
  7. . ../functions/download.sh
  8. . ../options.conf
  9. src_url=http://xcache.lighttpd.net/pub/Releases/$xcache_version/xcache-$xcache_version.tar.gz && Download_src
  10. tar xzf xcache-$xcache_version.tar.gz
  11. cd xcache-$xcache_version
  12. make clean
  13. $php_install_dir/bin/phpize
  14. ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=$php_install_dir/bin/php-config
  15. make && make install
  16. if [ -f "$php_install_dir/lib/php/extensions/`ls $php_install_dir/lib/php/extensions | grep zts`/xcache.so" ];then
  17. /bin/cp -R htdocs $home_dir/default/xcache
  18. chown -R ${run_user}.$run_user $home_dir/default/xcache
  19. touch /tmp/xcache;chown ${run_user}.$run_user /tmp/xcache
  20. Memtatol=`free -m | grep 'Mem:' | awk '{print $2}'`
  21. if [ $Memtatol -le 512 ];then
  22. xcache_size=40M
  23. elif [ $Memtatol -gt 512 -a $Memtatol -le 1024 ];then
  24. xcache_size=80M
  25. elif [ $Memtatol -gt 1024 -a $Memtatol -le 1500 ];then
  26. xcache_size=100M
  27. elif [ $Memtatol -gt 1500 -a $Memtatol -le 2500 ];then
  28. xcache_size=160M
  29. elif [ $Memtatol -gt 2500 -a $Memtatol -le 3500 ];then
  30. xcache_size=180M
  31. elif [ $Memtatol -gt 3500 ];then
  32. xcache_size=200M
  33. fi
  34. cat >> $php_install_dir/etc/php.ini << EOF
  35. [xcache-common]
  36. extension = "xcache.so"
  37. [xcache.admin]
  38. xcache.admin.enable_auth = On
  39. xcache.admin.user = "admin"
  40. xcache.admin.pass = "$xcache_admin_md5_pass"
  41. [xcache]
  42. xcache.size = $xcache_size
  43. xcache.count = $(expr `cat /proc/cpuinfo | grep -c processor` + 1)
  44. xcache.slots = 8K
  45. xcache.ttl = 3600
  46. xcache.gc_interval = 300
  47. xcache.var_size = $xcache_size
  48. xcache.var_count = $(expr `cat /proc/cpuinfo | grep -c processor` + 1)
  49. xcache.var_slots = 8K
  50. xcache.var_ttl = 0
  51. xcache.var_maxttl = 0
  52. xcache.var_gc_interval = 300
  53. xcache.test = Off
  54. xcache.readonly_protection = Off
  55. xcache.shm_scheme = "mmap"
  56. xcache.mmap_path = "/tmp/xcache"
  57. xcache.coredump_directory = ""
  58. xcache.cacher = On
  59. xcache.stat = On
  60. xcache.optimizer = Off
  61. [xcache.coverager]
  62. ; enabling this feature will impact performance
  63. ; enable only if xcache.coverager == On && xcache.coveragedump_directory == "non-empty-value"
  64. ; enable coverage data collecting and xcache_coverager_start/stop/get/clean() functions
  65. xcache.coverager = Off
  66. xcache.coverager_autostart = On
  67. xcache.coveragedump_directory = ""
  68. EOF
  69. [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
  70. else
  71. echo -e "\033[31meXcache module install failed, Please contact the author! \033[0m"
  72. fi
  73. cd ..
  74. /bin/rm -rf xcache-$xcache_version
  75. cd ..
  76. }