1、安装libevent函数库
下载地址:http://libevent.org
可以通过#ls -al /usr/local/lib | grep libevent
命令查看是否已安装libevent函数库。
如果没安装,则需下载并安装libevent函数库。
方法一:
#下载--解压--指向
wget https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz
tar -zxvf libevent-2.1.11-stable.tar.gz
cd libevent-2.1.11-stable
#指定安装目录
./configure --prefix=/usr/local/libevent
#安装
make && make install
方法二:
yum -y install libevent libevent-devel
2、安装memached服务端
下载地址: https://www.memcached.org/
方法一:
yum install memcached
方法二:
#下载--解压--指向
wget https://www.memcached.org/files/memcached-1.6.6.tar.gz
tar -zxvf memcached-1.6.6.tar.gz
cd memcached-1.6.6
#指定安装目录
./configure --prefix=/usr/local/memcached
#安装
make && sudo make install
3、需要编译安装libmencached
下载地址:https://launchpad.net/libmemcached/+download
#下载--解压--指向
wget 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 --prefix=/usr/local/libmemcached
./configure --prefix=/usr/local/libmemcached --with-memcached
#安装
make && make install
4、Memcached扩展包的生成
下载地址: http://pecl.php.net/package/memcached/
#下载--解压--指向
wget wget http://pecl.php.net/get/memcached-3.1.5.tgz
tar -zxvf memcached-3.1.5.tgz
cd memcached-3.1.5
phpize
#指定安装目录
#./configure --with-memcached --with-libmemcached --with-php-config=/usr/local/php/bin/php-config disable-memcached-sasl
#./configure --with-memcached=/usr/local/memcached --with-libmemcached=/usr/local/libmemcached --with-php-config=/usr/local/php/bin/php-config --disable-memcached-sasl
./configure --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/ --enable-memcached
sudo ./configure -prefix=/usr/local/libmemcached --with-memcached
#安装
make && make install
5、 配置并重启服务器
把生成的memcached.so拷贝到你的php.ini:
extension=memcached.so
重启服务:
方法一:
service php-fpm restart
方法二:
systemctl start php-fpm
启动memcached:
./memcached -d -u nobody -m 512 127.0.0.1 -p 11211
/usr/local/memcached/bin/memcached -d -l 127.0.0.1 -p 11211 -u root -m 64 -c 1024 -P /var/run/memcached.pid