php扩展libzookeeper(https://github.com/timandes/libzookeeper)主要用于使用php代码连接zookeeper集群。
扩展对原zookeeper c client(https://zookeeper.apache.org/)的功能进行了简化,强调简单性与易用性。
同时,本着开放的精神,允许更多的参与到zookeeper的开发与使用当中。
libzookeeper扩展依赖于zookeeper c client,后者包含在zookeeper的安装包中,具体安装方法参看:https://zookeeper.apache.org/doc/r3.5.0-alpha/zookeeperprogrammers.html#installation。
下面介绍libzookeeper的安装步骤(以v0.3.1为例):
1)下载并解压缩安装包:
wget https://github.com/timandes/libzookeeper/archive/v0.3.1.tar.gz libzookeeper-0.3.1.tar.gz
tar xvf libzookeeper-0.3.1.tar.gz
2)编译并安装扩展:
cd libzookeeper-0.3.1
phpize
./configure --with-libzookeeper=/path/to/zookeeper_c_client
make
make install
其中,/path/to/zookeeper_c_client代表已安装好的zookeeper c client的路径。
3)编辑php.ini,插入如下代码行:
extension=libzookeeper.so
4)如果使用php-fpm,则需要重启该服务:
service php-fpm restart
5)检查扩展加载情况:
php -m | grep libzookeeper
在安装过程中出现任何问题,均可以前往https://github.com/timandes/libzookeeper发问。