下面是 PHP 生产、消费 Kafka 消息的例子(假设已经配置好 Kafka): 1.从 zookeeper 源码 src/c/src 安装 zookeeper c client cd zookeeper-3.4.10/src/c ./configure make && make install 或者 编译 php libzookper 扩展 git clone https://github.com/Timandes/libzookeeper.git cd libzookeeper phpize ./configure --with-libzookeeper=/usr/local/bin/cli_mt make && make install 编译 php zookeeper 扩展 git clone https://github.com/php-zookeeper/php-zookeeper.git cd php-zookeeper phpize ./configure make && make install 4.修改 php.ini 配置,添加 libzookeeper 和 php-zookeeper 扩展 vim /etc/php/7.0/cli/php.ini extension=libzookeeper.so extension=zookeeper.so root@alex-virtual-machine:/usr/src/libzookeeper# /etc/init.d/php7.0-fpm restart root@alex-virtual-machine:/usr/src/libzookeeper# service nginx restart
安装php
http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.4.8/zookeeper-3.4.8.tar.gz
/root/zookeeper-3.4.8/src/c
./configure -prefix=/usr/local/zookeeper/zookeeper-3.4.8/
php 扩展
./configure –with-php-config=/usr/bin/php-config -with-libzookeeper-dir=/usr/local/zookeeper/zookeeper-3.4.8/nginx
安装 librdkafkagit
https://github.com/edenhill/librdkafkagithub
./configure
make
sudo make install
更多内容关注个人订阅号apache
我的博客 www.zxb8.cc 自学吧vim