linux配置phpkafka扩展

2020-12-21 06:33:07   PHP

  Kafka,Php-Kafka  

1、下载扩展

[root@ecs-s6-large-2-linux-20201108111405 ~]# git clone https://github.com/arnaud-lb/php-rdkafka.git
2、执行phpize生成configure文件

phpize

3、编译安装

[root@ecs-s6-large-2-linux-20201108111405 php-rdkafka]# ./configure --with-php-config=/www/server/php/72/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /www/server/php/72
checking for PHP includes... -I/www/server/php/72/include/php -I/www/server/php/72/include/php/main -I/www/server/php/72/include/php/TSRM -I/www/server/php/72/include/php/Zend -I/www/server/php/72/include/php/ext -I/www/server/php/72/include/php/ext/date/lib
checking for PHP extension directory... /www/server/php/72/lib/php/extensions/no-debug-non-zts-20170718
checking for PHP installed headers prefix... /www/server/php/72/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for rdkafka support... yes, shared
checking for librdkafka/rdkafka.h" in default path... not found
configure: error: Please reinstall the rdkafka distribution

结果编译安装报错

解决办法如下

git下载librdkafka https://github.com/edenhill/librdkafka.git

执行编译安装

./configure

make&&make install

执行完成后返回php-rdkafka目录再次执行一遍./configure make&&make install

编辑php配置文件php.ini

extension=rdkafka.so


完成  搞定!