首页 > 代码库 > 03-PHP的各种扩展

03-PHP的各种扩展

【安装memcached】
[安装 libevent]
$ tar zxvf libevent-2.0.20-stable.tar.gz
$ cd libevent-2.0.20-stable/
$ ./configure --prefix=/usr/local/libevent
$ make && make install
 
[安装memcached服务端]
$ tar zxvf memcached-1.4.39.tar.gz
$ ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
$ make && make install
 
[启动]
$ cd /usr/local/memcached
$ ./memcached -u root –d #启动memcached
$ ps -ef |grep memcached     #查看memcached运行状态
 
【备注】设置memcached开机启动,vim打开/etc/rc.local在最后面写入:
/usr/local/memcached/bin/memcached -u root -d
 
[连接]
$telnet 127.0.0.1 11211
stats     --查看状态
version       --查看版本
set user 1 3000 10 --添加数据
get user  --获取数据
delete user    --删除数据
flush_all --清空所有
 
 
安装php-memcached扩展】
[安装 libmemcached]
$ tar zxvf libmemcached-1.0.18.tar.gz
$ cd libmemcached-1.0.18/
$ ./configure --prefix=/usr/local/libmemcached --with-memcached --enable-sasl
$ make && make install
 
[安装 php-memcached扩展]
[https://github.com/php-memcached-dev/php-memcached]
$ unzip php-memcached-php7.zip
$ cd php-memcached-php7/
$ /usr/local/php/bin/phpize
$ ./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --enable-memcached-sasl
$ make && make install
 
安装完成后,在php.ini 后面添加 extension=memcached.so
 
 
 
 
 
 
 
 
 

03-PHP的各种扩展