I installed PHP 7.4 and RdKafka by using PECL however the module didn't start, here is the output of php -v
PHP Warning: PHP Startup: rdkafka: Unable to initialize module
Module compiled with module API=20210902
PHP compiled with module API=20190902
These options need to match
I assume that maybe my rdkafka module is to recent for this PHP binary, and I tried to install older version by doing ->
sudo pecl uninstall rdkafka && sudo pecl install rdkafka-4.0.0
According to pecl.php.net website, this version is the closest to my PHP binary compiled module ( https://pecl.php.net/package/rdkafka )
However there is an error while compiling the source code of this version.
make: *** [Makefile:205: rdkafka.lo] Error 1
I also tried several solutions proposed on various sources but I can not figure out how to make it work, and I havnt used PHP for like 10 years so my knowledge are very bad.
Anyone know how to fix or can give me some lead ?
My Answer:
One possible solution to this issue is to try compiling the RdKafka module from the source code instead of using PECL. Here are the steps to do so:
1. Download the source code for the RdKafka module from the Github repository: https://github.com/arnaud-lb/php-rdkafka
2. Extract the source code to a directory on your system.
3. Navigate to the directory where you extracted the source code and run the following commands to compile the module:
phpize
./configure
make
sudo make install
4. Once the compilation is complete, update your php.ini file to include the RdKafka module. You can do this by adding the following line to your php.ini file:
extension=rdkafka.so
5. Restart your web server to apply the changes.
By compiling the RdKafka module from the source code, you can ensure that it is compatible with your PHP 7.4 installation. This should resolve the module version mismatch issue you are experiencing.
Rate this post
5 of 5 based on 3038 votesComments