Installed PHP RdKafka extension

Install PHP Rdkafka extension user default system on linux

On Debian and Ubuntu, install librdkafka from the Confluent APT repositories, see instructions here and then install librdkafka:

$ apt install librdkafka-dev

On RedHat, CentOS, Fedora, install librdkafka from the Confluent YUM repositories, instructions here and then install librdkafka:

$ yum install librdkafka-devel

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.  (Skip if you already installed librdkafka-dev) Add backports repository. Current ext-rdkafka depends on librdkafka version 0.11.0 or greater. So follow official instructions, but use stretch-backports.
  3. (Skip if you already installed librdkafka-dev) 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.

     

Ref: https://github.com/edenhill/librdkafka?ref=morioh.com&utm_source=morioh.com#installation

Ref: https://stackoverflow.com/questions/47676416/how-do-i-install-an-extension-of-kafka-for-php

Tutorial:

  1. https://bestofphp.com/repo/arnaud-lb-php-rdkafka
  2. Install: https://arnaud-lb.github.io/php-rdkafka-doc/phpdoc/rdkafka.setup.html
  3. Example: https://arnaud-lb.github.io/php-rdkafka-doc/phpdoc/rdkafka.examples.html
  4. pecl: https://pecl.php.net/package/rdkafka

Leave a Reply

Your email address will not be published.