How to Install the PHP GnuPG Extension

In the examples shown, replace "X.Y" with your app's PHP version (for example, "7.1"). To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.

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.

Installing GnuGP on PHP

As a PECL extension, GnuGP 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 GnuGP extension on PHP 7.X or 5.X, 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 > /etc/phpX.Y-sp/conf.d/gnupg.ini"
sudo service phpX.Y-fpm-sp restart

Verifying GnuGP Is Installed

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:

gnupg support => enabled

Uninstalling the GnuPG Extension

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

Last updated: February 26, 2018