【1】下载与安装
【1.1】官网
文档:https://github.com/memcached/memcached/wiki/Install
我们直接就下最新版吧。Wiki 那里就是官方手册
【1.2】前置依赖 libevent 下载安装
(1)下载:wget https://github.com/libevent/libevent/releases/download/release-2.1.11-stable/libevent-2.1.11-stable.tar.gz
(2)解压:tar -zxvf libevent-2.1.11-stable.tar.gz
(3)安装:
cd libevent-2.1.11-stable/
./configure --prefix=/usr
make && make install
【1.3】memcached 下载、解压、安装
(1)下载:wget http://memcached.org/latest
(2)解压:tar -zxvf latest
(3)安装
cd memcached-1.6.6
./configure -with-libevent=/usr --prefix=/usr/local/memcached
mkdir -p /usr/local/memcached
make && make install
#如果不指定 --prefix,那么默认启动命令在 /usr/local/bin/memcache
#那么我们现在的目录是 /usr/local/memcache/bin
【2】启动关闭与连接
【2.1】启动与关闭 Memcached 服务
(1)linux
cd /usr/local/bin
./memcached -d -m 10 -u root -l 192.168.239.131 -p 11211 -c 256 -P /tmp/memcached.pid
#也可以加入到环境变量 echo "export PATH=${PATH}:/usr/local/memcached/bin/">>/etc/profile
#默认:/usr/local/bin/memcached -d -m 10 -u root -l 192.168.239.131 -p 11211 -c 256 -P /tmp/memcached.pid
#-d(后台启动) -m(内存,默认为M) -c(并发数)
(2)windows
(1)直接启动:d:\memcached\memcached.exe -d RunService -l 192.168.239.131 -p 11211 -m 500
(2)封装成服务器:sc.exe create Memcached_srv binpath="d:\memcached\memcached.exe -d RunService -p 11211 -m 500" start=auto
net start memcached
(3)关闭
直接Kill掉进程即可
【2.3】telnet 核验
telnet 192.168.239.131 11211
这样就算登录上来了,输入stats,可以查看 memcached 的当前参数情况(输入 quit 可以退出)
【3】基本命令教程
参考菜鸟驿站:https://www.runoob.com/memcached/memcached-set-data.html
【4】PHP与 Memcached 整合
https://www.php.cn/course/52.html
来源:oschina
链接:https://my.oschina.net/u/4362791/blog/4292331