centos系统为php安装memcached扩展步骤

这篇文章主要介绍了centos系统为php安装memcached扩展的步骤,大家参考使用吧 1.通过yum安装 yum -y install memcached \#安装完成后执行: memcached -h \#出现memcached帮助信息说明安装成功 2.加入启动服务 chkconfig --

centoslinuxPHP

这篇文章主要介绍了centos系统为php安装memcached扩展的步骤,大家参考使用吧

1.通过yum安装

yum -y install memcached #安装完成后执行: memcached -h #出现memcached帮助信息说明安装成功

2.加入启动服务

chkconfig --level 2345 memcached on

3.配置Memcached

vim /etc/sysconfig/memcached #文件中内容如下,按需要修改:

PORT="11211" #端口
USER="root" #用户名
MAXCONN="1024" #最大连接数
CACHESIZE="64" #内存大小
OPTIONS="" #附加参数
4.安装libmemached

wget https://launchpad.net/libmemcached/1.0/1.0.16/+download/libmemcached-1.0.16.tar.gz tar -zxvf libmemcached-1.0.16.tar.gz cd libmemcached-1.0.16 ./configure -prefix=/usr/local/libmemcached -with-memcached make && make install 注意:这里容易报错, 编译错误: libmemcached/auto.cc: In function 'memcached_return_t text_incr_decr(memcached_server_st*, bool, const char*, size_t, uint64_t, bool)': libmemcached/auto.cc:73: error: expected `)' before 'PRIu64'

In file included from ./libmemcached/common.h:72, from ./libmemcached/csl/common.h:40, from libmemcached/csl/context.cc:38: ./libmemcached-1.0/memcached.h:46:27: error: tr1/cinttypes: No such file or directory 原因是gcc版本过低了 对策:libmemcached-1.0.2 版本以上升级编译器版本 # yum install gcc44 gcc44-c++ libstdc++44-devel

# export CC=/usr/bin/gcc44 # export CXX=/usr/bin/g++44 # ./configure

如果升级gcc版本出现连接源的问题不能下载,可以换用163的yum源,参考文章

https://www.zhizhi123.com/blog/2015/08/25/centos-yum-163-source/

5.安装php-devel

yum install php-devel

6.安装PHP Memcached扩展

wget http://pecl.php.net/get/memcached-2.1.0.tgz tar -zxvf memcached-2.1.0.tgz cd memcached-2.1.0 /usr/local/php/bin/phpize ./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 make && make install

ABOUT THE AUTHOR

织织

前大厂程序员、AI 工具开发者,正在记录从技术到产品的实践。

关于作者
DISCUSSION

评论与讨论

留下你的想法