Befire installation
- apt list —upgradable # check for php8.3 version installed
- apt remove php8.3-dev php8.3-test… # uninstall all php8.2 extension so that it wll not conflict to php8.2
- apt autoremove
rdkafka extension for PHP 8.2 only, while ensuring that PHP 8.3 is not affected, follow these steps carefully. I’ll also include verification steps after each part.
Steps for Fresh Installation of rdkafka Extension for PHP 8.2 (CLI and FPM)
1. Remove any previous rdkafka installations
We will first remove any existing configurations or installations related to therdkafka extension.
2. Install dependencies
We need to install the required libraries and tools for building PHP extensions and Kafka support.3. Install the rdkafka extension via PECL for PHP 8.2
Use the PECL command to install therdkafka extension. Since your server has both PHP 8.2 and PHP 8.3, we will ensure to install for PHP 8.2 specifically.
4. Enable the rdkafka extension in PHP 8.2 for CLI and FPM
Once the extension is installed, we need to enable it for both PHP 8.2 CLI and FPM.5. Verify the installation for CLI and FPM
After installation, let’s verify that rdkafka is loaded correctly for both PHP CLI and PHP-FPM.
6. Check PHP version
Make sure the correct version of PHP is being used for CLI and FPM.7. Restart PHP-FPM and Apache/Nginx (if applicable)
After enabling the extension, restart PHP-FPM and web server (if you use Apache or Nginx) to make sure the extension is loaded correctly in the web environment.8. Verify the rdkafka extension in your web environment
Now, verify if therdkafka extension is working with a simple PHP script.
Create a PHP file to check the loaded modules:
http://your_server_ip/phpinfo.php and look for rdkafka in the output to confirm it is loaded.
Summary of the Steps
- Remove previous installations of
rdkafka. - Install required dependencies and PHP 8.2 development packages.
- Install
rdkafkaextension usingpecl. - Enable the extension in the appropriate
.inifiles for CLI and FPM. - Restart PHP-FPM and web server.
- Verify the installation with
php -mandphpinfo().
Final Verification
After following the steps above, you should see therdkafka extension listed when running php -m, and it should be active both in the CLI and FPM contexts. If everything is successful, the warning should be gone and the extension will be properly loaded. Let me know how it goes!