PHP + Memcache 实现多服务器session共享 (补充)

先说系统环境

wdcp 的安装包,就不用多说了,具体的看这篇博文  

wdcp 或者 阿里云一键安装包 再也不用担心 服务器环境搭建了


然后也是用wdcp 官网提供的安装 memcache 的脚本

[教程] memcached的启用和设置


http://www.wdlinux.cn/bbs/thread-1373-1-1.html

实际安装的过程中报错,提示这个包没有 libevent-1.4.14b-stable.tar.gz

https://cloud.github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz ---- 到这个地址下载

或者这个地址

http://image.520happy.cn/yum/libevent-1.4.14b-stable.tar.gz ---- 到这个地址下载


下面这个脚本亲测,可以正常安装


#!/bin/bash
# Memcache install scripts
# Author:wdlinux
# Url http://www.wdlinux.cn

echo "Select php version:
    1 php-5.2.17 (default)
    2 php-5.3.27
"
sleep 0.1
read -p "Please Input 1,2: " PHP_VER_ID
if [[ $PHP_VER_ID == 2 ]]; then
    PHP_VER="5.3.27"
    ext_dir="no-debug-non-zts-20090626"
else
    PHP_VER="5.2.17"
    ext_dir="no-debug-zts-20060613"
fi
TOP=$(cd $(dirname $0)/.. && pwd)
###
if [ ! -f /usr/bin/gcc ]; then
    yum install -y gcc gcc-c++ make autoconf libtool-ltdl-devel \
        gd-devel freetype-devel libxml2-devel libjpeg-devel \
        libpng-devel openssl-devel curl-devel patch libmcrypt-devel \
        libmhash-devel ncurses-devel sudo bzip2
fi
yum install -y zlib-devel

###
cd /tmp
wget -c https://cloud.github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz
wget -c http://dl.wdlinux.cn:5180/soft/memcached-1.4.15.tar.gz
wget -c http://pecl.php.net/get/memcache-2.2.7.tgz
tar xf libevent-1.4.14b-stable.tar.gz
cd libevent-1.4.14b-stable
./configure --prefix=/usr
make
[ $? != 0 ] && exit
make install
cd ..

tar xf memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure --prefix=/www/wdlinux/memcached --with-libevent=/usr
make
[ $? != 0 ] && exit
make install
cd ..

if grep -qi 'debian\|ubuntu' /etc/issue; then
    wget http://www.wdlinux.cn/conf/init.d/init.memcached-ubuntu -O /www/wdlinux/init.d/memcached
    chmod 755 /www/wdlinux/init.d/memcached
    ln -s /www/wdlinux/init.d/memcached /etc/init.d/memcached
    update-rc.d -f memcached defaults
    update-rc.d -f memcached enable 235
else
    wget http://www.wdlinux.cn/conf/init.d/init.memcached -O /www/wdlinux/init.d/memcached
    chmod 755 /www/wdlinux/init.d/memcached
    ln -s /www/wdlinux/init.d/memcached /etc/init.d/memcached
    chkconfig --level 35 memcached on
fi
touch /www/wdlinux/etc/memcached.conf
service memcached start

###
tar zxvf memcache-2.2.7.tgz
cd memcache-2.2.7
/www/wdlinux/php/bin/phpize
./configure --enable-memcache --with-php-config=/www/wdlinux/php/bin/php-config --with-zlib-dir
make
[ $? != 0 ] && exit
make install

grep -q 'memcache.so' /www/wdlinux/etc/php.ini
if [ $? != 0 ]; then
    echo "
[memcache]
extension_dir ="/www/wdlinux/php/lib/php/extensions/$ext_dir"
extension=memcache.so" >> /www/wdlinux/etc/php.ini
fi

if [ -d /www/wdlinux/apache ]; then
    service httpd restart
else
    service nginxd restart
fi

echo
echo "memcache install is OK"
echo


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值