How do I install an extension of Kafka for PHP?
Asked Answered
D

4

7

This is the extension that I am trying to install: https://github.com/EVODelavega/phpkafka

The messages passed to the queue should be in JSON format.

Currently, I am getting installation errors: 1. The instructions ask me to install librdkafka. 2. The installation link for the above step is this. I am unable to install using the 1st and 4th method. This is the error:

checking for librdkafka/rdkafka.h" in default path... not found
configure: error: Please reinstall the rdkafka distribution
Duron answered 6/12, 2017 at 14:16 Comment(0)
M
17

Quick Install Steps:

Step 1 Install PHP pecl and pear commands:

sudo apt install php-pear

Step 2 Install librdkafka

sudo apt-get install -y librdkafka-dev

Step 3 Install PECL-package

sudo pecl install rdkafka

Step4 Enable PHP-extension in PHP config. Add to php.ini

sudo nano /etc/php/7.4/cli/php.ini

extension=rdkafka.so

Step 4 Restart apache server

sudo service apache2 restart
Moralize answered 3/9, 2020 at 10:52 Comment(0)
M
6

because you need another package librdkafka,you should install librdkafka first

this way can resolve your problem

Manolete answered 18/1, 2019 at 11:7 Comment(0)
G
5

For Linux Debian Stretch (9.13) actual flow is:

  1. Install PHP pecl and pear commands:

    sudo apt install php-pear
    

    FYI: Depends on your installed PHP version you may need to use concrete version package. For example: php7.2-pear.

  2. Add backports repository. Current ext-rdkafka depends on librdkafka version 0.11.0 or greater. So follow official instructions, but use stretch-backports.

  3. Install librdkafka-dev package from backports:

    sudo apt -t stretch-backports install librdkafka-dev
    
  4. Update apt:

    sudo apt update
    
  5. Install PECL-package:

    sudo pecl install rdkafka
    
  6. Enable PHP-extension in PHP config. Add to php.ini:

    extension=rdkafka.so
    

    FYI: You need to restart php-fpm service to apply new config params.

Graham answered 28/7, 2020 at 10:58 Comment(0)
H
0

I'm using Manjaro OS and I did that steps:

https://arnaud.le-blanc.net/php-rdkafka-doc/phpdoc/rdkafka.installation.html

$ git clone https://github.com/arnaud-lb/php-rdkafka.git
$ cd php-rdkafka
$ phpize
$ ./configure
$ make all -j 5
$ sudo make install

And then in my php.ini (in /etc/php/php.ini) I added next line:

extension=rdkafka.so

And that everything just works fine.

Holarctic answered 11/7 at 5:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.