CentOS7.X安装memcached

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

    CentOS7.X安装memcached

上一篇:CentOS7.X安装Nginx


下一篇:CentOS7.X安装mongodb-3.4.2