PHP5.6与PHP7的memcached安装

因需要兼容旧系统,所以服务器还保留了PHP5.6,有些比较新的系统就直接上PHP7了
PHP5.6的安装位置是 /usr/local/php
PHP7的安装位置是 /usr/local/php7

在PHP上使用memcached,需要安装三个东西

  1. libmemcached
    libmemcached在yum服务器上版本比较低,不要yum install libmemcached,否则会导致安装php-memcached扩展的时候报错。
    请到这里下载最新版:https://launchpad.net/libmemcached/+download

wget -c https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz
tar -zxvf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure # 不需要设置安装目录
make && make install

  1. memcached缓存服务器
    memcached可以到这里下载:https://memcached.org/

wget -c http://www.memcached.org/files/memcached-1.5.7.tar.gz
tar -xvzf memcached-1.5.7.tar.gz
cd memcached-1.5.7
./configure –prefix=/usr/local/memcached –enable-64bit
make && make install

启动memcached服务

/usr/local/memcached/bin/memcached -u www -d -m 256m -p 11211

  1. php-memcached扩展
    下载地址:http://pecl.php.net/package/memcached
    PHP7安装

wget -c http://pecl.php.net/get/memcached-3.0.4.tgz
tar -zxvf memcached-3.0.4.tgz
cd memcached-3.0.4
/usr/local/php7/bin/phpize
./configure –with-php-config=/usr/local/php7/bin/php-config –disable-memcached-sasl
make && make install

PHP5.6只能安装2.x.x版本

wget -c http://pecl.php.net/get/memcached-2.1.0.tgz
tar -zxvf memcached-2.1.0.tgz
cd memcached-2.1.0
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –disable-memcached-sasl
make && make install

没啥技术含量,里面有些坑过几个月就可能要踩一次,记录下来,防止又忘了。

    原文作者:crazytang
    原文地址: https://www.jianshu.com/p/c24c87936c15
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞