上一次修改时间:2015-11-26 18:05:13

memcached安装

yum安装gcc,make,cmake,autoconf,libtool等工具;

  1. 下载memcached,libevent(memcached.org,libevent.org),memcached依赖于libevent,所以先得装libevent

  2. [pikaqiu@bogon memcached]$ wget http://www.memcached.org/files/memcached-1.4.25.tar.gz
    [pikaqiu@bogon memcached]$ wget https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
    [pikaqiu@bogon memcached]$ ls
    libevent-2.0.22-stable.tar.gz  memcached-1.4.25.tar.gz
  3. 安装libevent

  4. [root@bogon libevent-2.0.22-stable]# ./configure --prefix=/usr/local/libevent
    [root@bogon libevent-2.0.22-stable]# make && make install
  5. 安装memcached

  6. [root@bogon memcached-1.4.25]# ./configure --prefix=/usr/local/memcached \ 
    > --with-libevent=/usr/local/libevent
    [root@bogon memcached-1.4.25]# make && make install
  7. 将bin目录加入到环境变量中;

  8. [root@bogon memcached-1.4.25]# vim /etc/profile
  9. 编译PHP的memcached扩展

  10. 去http://pecl.php.net搜索扩展源码并下载,扩展对应的操作方法在扩展的文档里可以查看;

  11. 解压并进入到解压目录,运行php安装目录下phpize生成configure配置文件;

  12. [root@bogon memcached-2.2.0]# /usr/local/php/bin/phpize --with-php-config=/usr/local/php/bin/php-config
    Configuring for:
    PHP Api Version:         20100412
    Zend Module Api No:      20100525
    Zend Extension Api No:   220100525
  13. [root@bogon memcache-2.2.7]# ./configure --with-php-config=/usr/local/php/bin/php-config
    [root@bogon memcache-2.2.7]# make && make install
    Build complete.
    Don't forget to run 'make test'.
    
    Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
  14. 将扩展地址加入到PHP.INI中(extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/memcache.so);

  15. 启动memcached,将设置用户为pikaqiu(linux下不能使用root作用用户启动memcached),可使用内存为512M,并将其设为后台运行;

    [pikaqiu@bogon ~]$ memcached -u pikaqiu -m 512 -d