什么是PEAR
PEAR的全称是PHP Extension and Application Repository,是PHP的扩展库,采用PHP语言编写。所以我们可以直接下载,并在我们的代码中包含(include)扩展库。
什么是PECL
PECL的全称是PHP Extension Community Library,它也是PHP的扩展库。PECL的扩展都是采用C语言编写的,可以被载入PHP中,给PHP增加额外的功能,比如PHP的Mongo扩展。
memcache和memcached都是PECL中的项目
3、安装php的memcached扩展
[root@Node1 src]# tar xf memcached-3.0.3-php.tgz
[root@Node1 src]# cd memcached-3.0.3
[root@Node1 memcached-3.0.3]# ls
ChangeLog g_fmt.c php_libmemcached_compat.c php_memcached_server.c tests
config.m4 g_fmt.h php_libmemcached_compat.h php_memcached_server.h
config.w32 LICENSE php_memcached.c php_memcached_session.c
CREDITS memcached-api.php php_memcached.h php_memcached_session.h
fastlz memcached.ini php_memcached_private.h README.markdown
###此时没有configure文件,都说了是扩展当前是作为php的插件(模块)运行
[root@Node1 memcached-3.0.3]# /usr/local/php/bin/phpize
# 如果是yum安装的php,要安装了php-devel包才有这个命令
Configuring for:
PHP Api Version: 20160303
Zend Module Api No: 20160303
Zend Extension Api No: 320160303
[root@Node1 memcached-3.0.3]# ./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcached遇到报错:
checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir= to specify the prefix where libmemcached headers and library are located安装依赖了包libmemcached-devel还是报错
configure: error: no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check只能编译安装新版本的libmemcached,并启用sasl功能
解决步骤:
1)安装sasl
yum install cyrus-sasl
2)编译安装libmemcached并启用sasl功能
tar xf libmemcached-1.0.18.tar.gz
cd libmemcached-1.0.18
./configure --prefix=/usr/local/libmemcached --enable-sasl
make
make install