CentOS7.0安装memcache
-
安装mencached服务及memcache扩展
yum -y \ install \ vim \ memcached \ firewalld \
-
将memcache加入systemd
chkconfig --level 2345 memcached on
-
修改配置文件
vim /etc/sysconfig/memcached PORT="11211" USER="memcached" MAXCONN="1024" CACHESIZE="64" OPTIONS="" ESC :wq
-
添加运行用户memcached
useradd memcached
-
开启防火墙11211端口
systemctl enable firewalld systemctl start firewalld firewall-cmd --zone=public --add-port=11211/tcp --permanent firewall-cmd --reload
-
启动并设置开机启动
# 启动 systemctl start memcached # 开机启动 systemctl enable memcached # 停止 systemctl stop memcached # 重启 systemctl restart memcached
- 安装PHP-memcache扩展(参考php安装文档附录)
-
测试服务及扩展安装是否成功
vim /xxx/test.php <?php $mem = new Memcache(); $mem->connect("127.0.0.1",11211); $mem->set('key','This is first value',0,60); echo $val=$mem->get('key'); ESC :wq php /xxx/test.php
- 领支付宝红包支持作者