CentOS7.X安装memcached

  1. 云栖社区>
  2. 博客>
  3. 正文

CentOS7.X安装memcached

qq2233466866 2018-06-11 16:01:13 浏览748
展开阅读全文

CentOS7.0安装memcache

  1. 安装mencached服务及memcache扩展

    yum -y \
    install \
    vim \
    memcached \
    firewalld \
  2. 将memcache加入systemd

    chkconfig --level 2345 memcached on
  3. 修改配置文件

    vim /etc/sysconfig/memcached
    
    PORT="11211"
    USER="memcached"
    MAXCONN="1024"
    CACHESIZE="64"
    OPTIONS=""
    
    ESC
    :wq
  4. 添加运行用户memcached

    useradd memcached
  5. 开启防火墙11211端口

    systemctl enable firewalld
    systemctl start firewalld
    firewall-cmd --zone=public --add-port=11211/tcp --permanent
    firewall-cmd --reload
  6. 启动并设置开机启动

    # 启动
    systemctl start memcached
    # 开机启动
    systemctl enable memcached
    # 停止
    systemctl stop memcached
    # 重启
    systemctl restart memcached
  7. 安装PHP-memcache扩展(参考php安装文档附录)
  8. 测试服务及扩展安装是否成功

    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
  9. 领支付宝红包支持作者

    扫码领支付宝红包

网友评论

登录后评论
0/500
评论
qq2233466866
+ 关注