zoukankan      html  css  js  c++  java
  • cent os 7 安装memcached和php支持

    yum search memcached
    有了,可以进行安装了

    yum -y install memcached

    memcache关联php
    yum -y install php-pecl-memcache

    验证安装结果
    memcached -h
    php -m | grep memcache

    参数说明:
    -d选项是启动一个守护进程;
    -m是分配给memcache使用的内存数量,单位是mB,我这里是100mB;
    -u是运行memcache的用户,我这里是root;
    -l是监听的服务器IP地址我这里指定了服务器的IP地址192.168.0.100;
    -p是设置memcache监听的端口,我这里设置了11211,最好是1024以上的端口;
    -c选项是最大运行的并发连接数,默认是1024,我这里设置了512,按照你服务器的负载量来设定;
    -P是设置保存memcache的pid文件,我这里是保存在 /tmp/memcached.pid;

    memcache的基本设置
    启动memcache的服务端:
    memcached -d -m 100 -u root -l 192.168.0.100 -p 11211 -c 512 -P /tmp/memcached.pid

    需要php扩展,就用下面这个命令
    pecl install memcache

    少phpsize,运行yum install php-devel

    把php.ini中的extension_dir = “./”修改为
    extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/”
    #注释掉:添加一行来载入memcache扩展:extension=memcache.so

    设置开机启动
    chkconfig memcached on

    启动和停止
    service memcached start | stop
    或者
    /etc/init.d/memcached start | stop

    Memcache环境测试:
    运行下面的php文件,如果有输出This is a test!,就表示环境搭建成功。开始领略Memcache的魅力把!
    < ?php
    $mem = new Memcache;
    $mem->connect(“127.0.0.1″, 11211);
    $mem->set(‘key’, ‘This is a test!’, 0, 60);
    $val = $mem->get(‘key’);
    echo $val;
    ?>

  • 相关阅读:
    nodejs 访问mysql
    1.移动的矩形
    ubuntu 16.04 搜狗输入法无法中英文切换
    修改可选项文件实现自动连接数据库服务器
    Codeforces Round #374 (Div. 2)解题报告
    hihoCoder 1238 : Total Highway Distance(dfs + 二分)
    AIM Tech Round 3 (Div. 2) 题解
    Codeforces Round #367 (Div. 2) 题解
    图论模板集合
    poj1144Network (求割点模板题)
  • 原文地址:https://www.cnblogs.com/etiao/p/4516908.html
Copyright © 2011-2022 走看看