Blogger Information
Blog 27
fans 0
comment 1
visits 46234
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Memcached使用
学习使我快乐
Original
981 people have browsed it

一、安装依赖包

1、yum install -y libevent-devel

二、安装memcached

1、curl -O http://memcached.org/files/memcached-1.4.33.tar.gz

2、tar -zxvf memcached-1.4.33.tar.gz

3、cd memcached-1.4.33

4、./configure --prefix=/usr/local/memcached --enable-64bit

5、make && make install

开启服务:

cd /usr/local/memcached/bin

./memcached -u www -d

-p:指定端口,默认为11211

-m:指定内存,根据自己硬件设置

-u:指定用户,不能是root

-d:后台运行

三、安装 libmemcached

1、wget http://launchpad.net/libmemcached/1.0/1.0.2/+download/libmemcached-1.0.2.tar.gz  

2、tar -zxvf libmemcached-1.0.18.tar.gz

3、cd libmemcached-1.0.18

4、./configure --prefix=/usr/local/libmemcached --with-memcached

5、make && make install

四、安装php-memcached-php7

1、yum install unzip

2、https://github.com/php-memcached-dev/php-memcached 下载

3、cd php-memcached-master

4、vim /etc/profile   在末尾添加 /usr/local/php7/bin/  

5、source /etc/profile

6、phpize

7、./configure --with-php-config=/usr/local/php7/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached/

8、make && make install

9、将上步得到的路径添加到PHP配置文件:/usr/local/php7/etc/php.ini

extension="/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/memcached.so"

重庆php:service php-fpm restart

五、使用memcached

创建对象:new Memcached

添加服务器:addServer

添加键值对:set

根据键获取值:get

删除键值对:delete

增加指定数值:increment

减去指定数值:decrement

清空所有缓存:flush

六、设置session使用memcached保存

vim /usr/local/php7/etc/php.ini

session.save_handler = memcached

session.save_path = "127.0.0.1:11211"

  免责声明:本文来源于,由网友提供或网络搜集,仅供个人研究、交流学习使用,不涉及商业盈利目的。如有版权问题,请联系本站管理员予以更改或删除。优知网会定期发布程序开发相关趋势文章,包括 PHP、 Linux、 Mysql 等领域,敬请关注!最后大家可以扫描下方的赞赏码支持我,感谢大家!

微信赞赏小.png

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post