AMQP PHP Extension for Plesk PHP 8

This article describes how to install the PHP 8 AMQP extension for RabbitMQ on Plesk Obsidian Linux. Installation requires a shell session as the root user.


Preparation

To install the AMQP extension, you must first install the following packages:


apt-get update
apt-get install librabbitmq-dev plesk-php80-dev plesk-php81-dev plesk-php82-dev plesk-php83-dev plesk-php84-dev plesk-php85-dev zlib1g-dev gcc make


Before installing PHP extensions, you should create a server snapshot so that you can roll back the installation with just a few clicks in case of an error. Learn more →



Installing the AMQP Extension


After installing the required dependencies, AMQP must be installed separately for each PHP version:

printf "\n" | /opt/plesk/php/8.0/bin/pecl install amqp
printf "\n" | /opt/plesk/php/8.1/bin/pecl install amqp
printf "\n" | /opt/plesk/php/8.2/bin/pecl install amqp
printf "\n" | /opt/plesk/php/8.3/bin/pecl install amqp  
printf "\n" | /opt/plesk/php/8.4/bin/pecl install amqp
printf "\n" | /opt/plesk/php/8.5/bin/pecl install amqp


After installation, the new extension must be added to the PHP configuration:

echo "extension=amqp.so" > /opt/plesk/php/8.0/etc/php.d/amqp.ini
echo "extension=amqp.so" > /opt/plesk/php/8.1/etc/php.d/amqp.ini
echo "extension=amqp.so" > /opt/plesk/php/8.2/etc/php.d/amqp.ini
echo "extension=amqp.so" > /opt/plesk/php/8.3/etc/php.d/amqp.ini
echo "extension=amqp.so" > /opt/plesk/php/8.4/etc/php.d/amqp.ini
echo "extension=amqp.so" > /opt/plesk/php/8.5/etc/php.d/amqp.ini


To enable the new configuration via the Plesk web interface, the PHP handlers must be reloaded:

plesk bin php_handler --reread


Next, the affected PHP handlers must be restarted to use the new AMQP module:


Warning: Restarting the PHP modules will terminate and restart all running PHP processes. If you are performing this installation on a production system, we recommend making this change at night.


# PHP 8.0
systemctl restart plesk-php80-fpm

# PHP 8.1
systemctl restart plesk-php81-fpm

# PHP 8.2
systemctl restart plesk-php82-fpm

# PHP 8.3
systemctl restart plesk-php83-fpm

# PHP 8.4
systemctl restart plesk-php84-fpm

# PHP 8.5
systemctl restart plesk-php85-fpm