美文网首页PHP笔记
php-zookeeper扩展安装

php-zookeeper扩展安装

作者: 零一间 | 来源:发表于2017-11-02 19:38 被阅读335次

    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
    <?php
    $zc = new Zookeeper();
    $zc->connect('localhost:2181');
    //尝试查询节点数据
    var_dump($zc->get('/server_host'));
    
    $ /appServer/php5.6/bin/php -f test.php 
    string(32) "这是一个测试数据,哈哈!"
    

    到此结束!

    相关文章

      网友评论

      • 谁叫白马入梦船:老铁不行啊:
        checking for libzookeeper location... configure: error: zookeeper support requires libzookeeper. Use --with-libzookeeper-dir=<DIR> to specify the prefix where libzookeeper headers and library are located

      本文标题:php-zookeeper扩展安装

      本文链接:https://www.haomeiwen.com/subject/wbyapxtx.html