安装memcached、 php-pecl-memcached 扩展

本文介绍了如何使用yum安装memcached,并启动设置守护进程。接着详细阐述了下载并安装libmemcached和php-pecl-memcached扩展的步骤,包括修改配置文件和编译安装过程,最后在php.ini中添加扩展并重启httpd服务。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

yum安装memcached 

yum install memcached


启动memcached

/usr/bin/memcached -d -m 10 -u root -l 127.0.0.1 -p 11211 -c 500 -P /usr/run/memcached/memcached.pid

-d 启动一个守护进程

-m 内存使用大小,单位mb,默认64mb

-M return error on memory exhausted(rather than removing items)

-u 运行Memcahced的用户

-l 监听服务器IP地址,默认所有网卡

-p 设置Memcached的TCP监听端口,常用11211

-c 最大运行并发连接数,默认1024

-P 设置保存Memcache的pid文件 

(也可以启动多个守护进程,但是端口不能重复






安装包地址:

1、libmemcached地址:https://launchpad.net/libmemcached

2、memcached地址:http://pecl.php.net/package/memcached 


下载安装libmemcached:

1、wget url

2、tar zxvf libmemcached-0.42.tar.gz
3、cd libmemcached-0.42
4、./configure –prefix=/usr/local/libmemcached  –with-memcached
5、make && make install

下载安装memcached:

1、wget url

2、tar zxvf memcached-0.42.tar.gz

3、cd memcached-0.42

4、vim php_libmemcached_compat.h 修改include路径包含libmemcached扩展

  1. # wget http://pecl.php.net/get/memcached
  2. # mv memcached memcached.tar.gz
  3. # tar zxf memcached.tar.gz
  4. # cd memcached-2.2.0b1/
  5. # vi php_libmemcached_compat.h
  6. #ifndef PHP_LIBMEMCACHED_COMPAT
  7. #define PHP_LIBMEMCACHED_COMPAT
  8. /* this is the version(s) we support */
  9. #include <libmemcached/memcached.h>(修改为正确的路径)

5、/usr/bin/phpize

6、./configure -enable-memcached -with-php-config=/usr/bin/php-config -with-libmemcached-dir=/usr/local/libmemcached(指定libmemcached安装路径) --disable-memcached-sasl(忽略加密)

7、./configure –prefix=/usr/local/phpmemcached  –with-memcached (指定安装路径)

8、make && make install

9、vim /etc/php.ini 加上extension=memcached.so 重起httpd






评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值