php-zookeeper扩展安装

zookeeper安装

zookeeper中有一个C客户端为PHP-Zookeeper提供类库。

安装PHP-Zookeeper类库

zookeeper安装目录: /appServer/zookeeper-3.4.9

# /appServer/zookeeper-3.4.9/src/c
# ./configure
# make && make instal

安装php的zookeeper扩展

php目录:/appServer/php5.6
pecl地址:http://pecl.php.net/package/zookeeper

# wget http://pecl.php.net/get/zookeeper-0.4.0.tgz
# tar zxvf zookeeper-0.4.0.tgz
# cd zookeeper-0.4.0
# /appServer/php5.6/bin/phpize
# ./configure --with-php-config=/appServer/php5.6/bin/php-config --with-libzookeeper-dir
# make && make install
# vim php.ini
# extension=zookeeper.so

查看是否加载成功

# /appServer/php5.6/bin/php -m | grep zookeeper
zookeeper

程序测试:

$ cat test.php
connect('localhost:2181');
//尝试查询节点数据
var_dump($zc->get('/server_host'));

$ /appServer/php5.6/bin/php -f test.php 
string(32) "这是一个测试数据,哈哈!"

到此结束!

你可能感兴趣的:(php-zookeeper扩展安装)