The GnuPG extension allows you to encrypt and sign your data and communication while featuring a versatile key management system. GnuPG also allows you access to modules for many public key directories.
As a PECL extension, GnuPG is installed using the peclX.Y-sp command, replacing "X.Y" the version of PHP running your app. If you have multiple apps using multiple versions of PHP, you will need to follow these instructions for each version of PHP.
To install the GnuPG extension on PHP 5.4 through PHP 7.4, run the following commands as your server's root user:
sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install libgpgme11-dev
sudo peclX.Y-sp install gnupg sudo bash -c "echo extension=gnupg.so > /etc/phpX.Y-sp/conf.d/gnupg.ini" sudo service phpX.Y-fpm-sp restart
Confirm the installation worked by running this command:
phpX.Y-sp -i | grep -i gnupg
If the installation was successful, you will see output like the following:
/etc/php7.0-sp/conf.d/gnupg.ini, gnupg gnupg support => enabled
To uninstall this extension, as root run the commands:
sudo rm /etc/phpX.Y-sp/conf.d/gnupg.ini sudo peclX.Y-sp uninstall gnupg
Next, restart PHP-FPM with the command:
sudo service phpX.Y-fpm-sp restart