centos系统如何为php安装memcached扩展

1.通过yum安装

代码如下:

yum -y install memcached

#安装完成后执行:

memcached -h

#出现memcached帮助信息说明安装成功

2. 加入启动服务

代码如下:

chkconfig --level 2345 memcached on

3. 配置Memcached

代码如下:

  1. vim /etc/sysconfig/memcached
  2. #文件中内容如下,按需要修改:
  3. PORT="11211" #端口
  4. USER="root" #用户名
  5. MAXCONN="1024" #最大连接数
  6. CACHESIZE="64" #内存大小
  7. OPTIONS="" #附加参数

4. 安装libmemached

代码如下:

  1. wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz
  2. tar -zxvf libmemcached-1.0.16.tar.gz
  3. cd libmemcached-1.0.16
  4. ./configure -prefix=/usr/local/libmemcached -with-memcached
  5. make && make install

5. 安装php-devel

代码如下:

yum install php-devel

6. 安装PHP Memcached扩展

代码如下:

  1. wget http://pecl.php.net/get/memcached-2.1.0.tgz
  2. tar -zxvf memcached-2.1.0.tgz
  3. cd memcached-2.1.0
  4. /usr/local/php/bin/phpize
  5. ./configure -enable-memcached -with-php-config=/usr/local/php/bin/php-config -with-zlib-dir -with-libmemcached-dir=/usr/local/libmemcached -prefix=/usr/local/phpmemcached
  6. make && make install