• linux php 安装 memcache 扩展


    1. memcached依赖于libevent,需要先安装libevent。

    tar zxvf libevent-2.0.21-stable.tar.gz

    cd libevent-2.0.21-stable

    ./configure --prefix=/usr/local/libevent

    make

    make install

    2 安装memcached服务端

    # wget http://www.memcached.org/files/memcached-1.4.20.tar.gz
    # tar zxvf memcached-1.4.20.tar.gz
    # cd memcached-1.4.20

    # ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
    # make && make install

    启动
    /usr/local/memcached/bin/memcached -d -m 32 -u root -p 11211 -c 128 -P /usr/local/memcached/memcached.pid

    参数说明

    -d 选项是启动一个守护进程。
    -u root 表示启动memcached的用户为root。
    -m 是分配给Memcache使用的内存数量,单位是MB,默认64MB。
    -M return error on memory exhausted (rather than removing items)。
    -u 是运行Memcache的用户,如果当前为root 的话,需要使用此参数指定用户。
    -p 是设置Memcache的TCP监听的端口,最好是1024以上的端口。
    -c 选项是最大运行的并发连接数,默认是1024。
    -P 是设置保存Memcache的pid文件。

    3 php安装memcache扩展

    wget http://pecl.php.net/get/memcache-2.2.7.tgz
     tar zxvf memcache-2.2.7.tgz
     cd memcache-2.2.7

       /usr/local/php/bin/phpize  ### 生成configure 文件
     ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config 
     make

      make install

    4 PHP安装memcached扩展

    首先安装 扩展  

    # wget http://launchpadlibrarian.net/66527034/libmemcached-0.48.tar.gz
    # cd libmemcached-0.48
    # ./configure --prefix=/usr/local/libmemcached --with-memcached --with-libsasl-prefix --with-libsasl2-prefix  --with-memcached-sasl
    # make

     make install

     wget http://pecl.php.net/get/memcached-2.2.0.tgz
     cd memcached-2.2.0
     /usr/local/php/bin/phpize
     ./configure --enable-memcached --with-php-config=/usr/local/php/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached

    make

    make install 

    编译完成后修改php.ini添加

    extension=memcache.so

    extension=memcached.so

    重启php-fpm

    5  测试是否安装成功

  • 相关阅读:
    PHP简单模拟登录功能实例分享
    一个form表单,多个提交按钮
    jquery validation验证身份证号、护照、电话号码、email
    MockMvc和Mockito之酷炫使用
    Java8 Stream API
    第一章 Lambda表达式
    Java中线程顺序执行
    单元测试之获取Spring下所有Bean
    iBatis之type
    json解析之jackson ObjectMapper
  • 原文地址:https://www.cnblogs.com/jackspider/p/5690196.html
Copyright © 2020-2023  润新知