1.安装 libevent wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz tar -zxvf libevent-2.0.21-stable.tar.gz 进入目录
./configure --prefix=/usr/local/libevent
make
make install 2.安装 memcached wget -c http://memcached.org/files/memcached-1.5.7.tar.gz 解压并进入目录
./configure --with-libevent=/usr/local/libevent --prefix=/usr/local/memcached
make
make install 3.启动memcached /usr/local/memcached/bin/memcached -d -m 128 -l 127.0.0.1 -p 11211 ps -aux | grep memcached 4.开机启动 重启成效 vim /etc/rc.local
/usr/local/memcached/bin/memcached -d -m 128 -l 127.0.0.1 -p 11211 5.安装 php memcache扩展 wget -c https://github.com/websupport-sk/pecl-memcache/archive/php7.zip unzip php7.zip cd pecl-memcache-php7/ /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config make
make install cd /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
发现 多了一个 memcache.so 不是 memcached.so vim /usr/local/php7/etc/php.ini extension_dir = "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/" extension = memcache.so service php-fpm restart /usr/local/php7/bin/php -m 查看 会出现一个 memcache index.php
session_start();
if (!isset($_SESSION['TEST'])) {
$_SESSION['TEST'] = time();
} $_SESSION['TEST3'] = time();
$_SESSION['name'] = 'liwenkai';
print $_SESSION['TEST'];
print "<br><br>";
print $_SESSION['TEST3'];
print "<br><br>";
echo session_id(); test.php session_start();
$mem = new Memcache();
$mem->addServer('127.0.0.1',11211);
var_dump($mem->get(session_id()));