zoukankan      html  css  js  c++  java
  • linux安装memcache及memcache扩展

    一、安装libevent
    # wget http://www.monkey.org/~provos/libevent-2.0.12-stable.tar.gz
    # tar zxf libevent-2.0.12-stable.tar.gz 
    # cd libevent-2.0.12-stable
    #./configure  --prefix=/usr/local/lib
    # make && make install

    二、下载安装最新版本:http://memcached.org/downloads
    # wget http://memcached.org/files/memcached-1.4.20.tar.gz

    # cd memcached-1.4.20

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

    三、配置启动

    # vi /etc/rc.local  

    #!/bin/sh
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    touch /var/lock/subsys/local

    /usr/sbin/ntpdate ntpupdate.tencentyun.com >/dev/null 2>&1 &
    /usr/local/agenttools/agent/startagent.sh  /usr/local/agenttools/agent /dev/null

    #secu-tcs-agent bootstart, install at Tue Apr 29 17:21:38 CST 2014.
    /usr/local/sa/agent/secu-tcs-agent-mon-safe.sh > /dev/null 2>&1

    /usr/local/memcached/bin/memcached -p 12677 -U 0 -d -r -u root -m 2040 -c 1024 -t 4

    保存后退出,手动启动服务

    # /usr/local/memcached/bin/memcached -p 12677 -U 0 -d -r -u root -m 2040 -c 1024 -t 4

    注:如果出现/usr/local/memcached/bin/memcached: error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory异常在/etc/ld.so.conf中加入/usr/local/lib这一行,保存之后,再运行:/sbin/ldconfig –v更新一下配置即可。

    # vi /etc/ld.so.conf

    #  /sbin/ldconfig -V

    四、测试memcached

    # telnet 127.0.0.1 12677

    出现以下信息表示启动成功
    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.

    Linux下php安装memcache扩展

    安装环境:CentOS 6.4 

    PHP扩展memcache的作用是为了支持memcached数据库缓存服务器,下面是安装方法。

    1、下载

    下载地址:http://pecl.php.net/package/memcache

    文件名:memcache-3.0.8.tgz

    文件下载成功后上传至/usr/local目录

    2、安装

    [root@vm15 local]# tar -zxvf memcache-3.0.8.tgz
    root@vm15 local]# cd memcache-3.0.8
    [root@vm15 memcache-3.0.8]# /usr/bin/phpize
    Configuring for:
    PHP Api Version: 20131106
    Zend Module Api No: 20131226
    Zend Extension Api No: 220131226
    [root@vm15 memcache-3.0.8]# ./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config --with-zlib-dir  或者直接./configure
    [root@vm15 memcache-3.0.8]# make
    [root@vm15 memcache-3.0.8]# make install
    Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20131226/
    [root@vm15 memcache-3.0.8]# ll /usr/local/php/lib/php/extensions/no-debug-zts-20131226/

    total 2140
    -rwxr-xr-x. 1 root root 453766 Dec 30 17:44 memcache.so
    -rwxr-xr-x. 1 root root 861055 Dec 30 16:47 Redis.so

    出现memcache.so就表明安装成功了

     tips:

         configure: error: memcache support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located

         yum 安装     #yum install zlib-devel

    3、配置支持php

    [root@vm15 memcache-3.0.8]# vi + /usr/local/php/lib/php.ini
    添加
    extension=memcache.so
    :wq! #保存退出

    4、重启服务

    #/etc/init.d/php-fpm restart

  • 相关阅读:
    分页 存储过程
    Base64编码
    汉字转拼音 完整类
    C#利用SharpZipLib解压或压缩文件夹实例操作
    C#压缩解压zip 文件
    MapReduce shuffle原理
    设计模式(一)—— 代理模式
    Lombok的基本使用
    解决idea 每次新建项目需要重新配置maven
    10-20 Spring框架(三)—— AOP核心
  • 原文地址:https://www.cnblogs.com/chenchenphp/p/6699895.html
Copyright © 2011-2022 走看看