VPS侦探论坛

 找回密码
 注册
查看: 8283|回复: 2

Memcached 1.4.20 for PHP5.5.14

[复制链接]
发表于 2014-7-13 22:36:49 | 显示全部楼层 |阅读模式

使用的是LNMP1.1一键安装包。
由于更新升级到PHP5.5.14版本,LNMP1.1自带的memcached.sh脚本是for1.0的,没有PHP5.5.x以上支持。
因此修改了安装脚本可以支持PHP5.5.x的,安装。脚本版本号改成了1.01,Memcached 也更新到最新官方1.4.20。
Memcached 1.4.20 for PHP5.5.14 /******生产环境下使用,请自行测试,本修改仅供测试,不对其稳定性负责。
附件
memcached.sh 覆盖"/root/lnmp1.1-full"使用,请自行做好备份。
(⊙o⊙)…,没找到附件怎么发。
vim /root/lnmp1.1-full/memcached.sh
  1. #!/bin/bash
  2. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
  3. export PATH

  4. # Check if user is root
  5. if [ $(id -u) != "0" ]; then
  6.     echo "Error: You must be root to run this script, please use root to install lnmp"
  7.     exit 1
  8. fi

  9. clear
  10. printf "=======================================================================\n"
  11. printf "Install Memcached for LNMP V1.01 ,  Written by Licess \n"
  12. printf "=======================================================================\n"
  13. printf "LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux \n"
  14. printf "This script is a tool to install memcached for lnmp \n"
  15. printf "\n"
  16. printf "For more information please visit http://www.lnmp.org \n"
  17. printf "=======================================================================\n"
  18. cur_dir=$(pwd)

  19.         get_char()
  20.         {
  21.         SAVEDSTTY=`stty -g`
  22.         stty -echo
  23.         stty cbreak
  24.         dd if=/dev/tty bs=1 count=1 2> /dev/null
  25.         stty -raw
  26.         stty echo
  27.         stty $SAVEDSTTY
  28.         }
  29.         echo ""
  30.         echo "Press any key to start install Memcached..."
  31.         char=`get_char`

  32. printf "=========================== install memcached ======================\n"

  33. if [ -s /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/memcache.so ]; then
  34.         rm -f /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/memcache.so
  35. elif [ -s /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so ]; then
  36.         rm -f /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/memcache.so
  37. elif [ -s /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so ]; then
  38.         rm -f /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so
  39. fi

  40. cur_php_version=`/usr/local/php/bin/php -v`

  41. if echo "$cur_php_version" | grep -q "5.2."
  42. then
  43. sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension = "memcache.so"\n#' /usr/local/php/etc/php.ini
  44. elif echo "$cur_php_version" | grep -q "5.3."
  45. then
  46. sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"\nextension = "memcache.so"\n#' /usr/local/php/etc/php.ini
  47. elif echo "$cur_php_version" | grep -q "5.4."
  48. then
  49. sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/"\nextension = "memcache.so"\n#' /usr/local/php/etc/php.ini
  50. elif echo "$cur_php_version" | grep -q "5.5."
  51. then
  52. sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"\nextension = "memcache.so"\n#' /usr/local/php/etc/php.ini
  53. else
  54.         echo "Error: can't get php version!"
  55.         echo "Maybe your php was didn't install or php configuration file has errors.Please check."
  56.         sleep 3
  57.         exit 1
  58. fi

  59. echo "Install memcache php extension..."
  60. wget -c http://soft.vpser.net/web/memcache/memcache-3.0.8.tgz
  61. tar zxvf memcache-3.0.8.tgz
  62. cd memcache-3.0.8/
  63. /usr/local/php/bin/phpize
  64. ./configure --with-php-config=/usr/local/php/bin/php-config
  65. make && make install
  66. cd ../

  67. wget -c http://soft.vpser.net/lib/libevent/libevent-2.0.13-stable.tar.gz
  68. tar zxvf libevent-2.0.13-stable.tar.gz
  69. cd libevent-2.0.13-stable/
  70. ./configure --prefix=/usr/local/libevent
  71. make&& make install
  72. cd ../

  73. echo "/usr/local/libevent/lib/" >> /etc/ld.so.conf
  74. ln -s /usr/local/libevent/lib/libevent-2.0.so.5  /lib/libevent-2.0.so.5
  75. ldconfig

  76. cd $cur_dir
  77. echo "Install memcached..."
  78. wget -c http://memcached.org/files/memcached-1.4.20.tar.gz
  79. tar zxvf memcached-1.4.20.tar.gz
  80. cd memcached-1.4.20/
  81. ./configure --prefix=/usr/local/memcached
  82. make &&make install
  83. cd ../

  84. ln /usr/local/memcached/bin/memcached /usr/bin/memcached

  85. cd $cur_dir
  86. cp conf/memcached-init /etc/init.d/memcached
  87. chmod +x /etc/init.d/memcached
  88. useradd -s /sbin/nologin nobody

  89. if [ ! -d /var/lock/subsys ]; then
  90.   mkdir -p /var/lock/subsys
  91. fi

  92. if [ -s /etc/debian_version ]; then
  93. update-rc.d -f memcached defaults
  94. elif [ -s /etc/redhat-release ]; then
  95. chkconfig --level 345 memcached on
  96. fi

  97. echo "Copy Memcached PHP Test file..."
  98. cp conf/memcached.php /home/wwwroot/default/memcached.php

  99. if [ -s /etc/init.d/httpd ] && [ -s /usr/local/apache ]; then
  100.         echo "Restart Apache......"
  101.         /etc/init.d/httpd -k restart
  102. else
  103.         echo "Restart php-fpm......"
  104.         /etc/init.d/php-fpm restart
  105. fi

  106. echo "Starting Memcached..."
  107. /etc/init.d/memcached start

  108. printf "===================== install Memcached completed =====================\n"
  109. printf "Install Memcached completed,enjoy it!\n"
  110. printf "You Can visit Memcached PHP Test file: http://ip/memcached.php\n"
  111. printf "=======================================================================\n"
  112. printf "Install Memcached for LNMP V1.01 ,  Written by Licess \n"
  113. printf "=======================================================================\n"
  114. printf "LNMP is a tool to auto-compile & install Nginx+MySQL+PHP on Linux \n"
  115. printf "This script is a tool to install Memcached for lnmp \n"
  116. printf "\n"
  117. printf "For more information please visit http://www.lnmp.org \n"
  118. printf "=======================================================================\n"
复制代码

[ 本帖最后由 iTimer 于 2014-7-13 22:40 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2014-10-9 14:09:33 | 显示全部楼层


Starting php-fpm [09-Oct-2014 14:05:20] NOTICE: PHP message: PHP Warning:  PHP Startup: memcache: Unable to initialize module
Module compiled with module API=20090626
PHP    compiled with module API=20121212
These options need to match
in Unknown on line 0
done

哥们,5.5装完启动这样了。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2014-10-9 14:12:29 | 显示全部楼层

我的是PHP Version 5.5.17
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-5-5 08:23 , Processed in 0.025933 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表