Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 16.04 - Install GPG Extension for PHP 7

Below is a script you can run to install the GPG extension for the PHP 7.0 CLI on Ubuntu 16.04. It may work on other distributions and versions of PHP, but I have not tested that.

Related Posts

Script

#!/bin/bash
sudo apt install libgpgme11-dev php-pear php7.0-dev -y
sudo pecl install gnupg

# Update the php.ini files for Apache and the CLI
SEARCH=";   extension=msql.so"
REPLACE=";   extension=msql.so\nextension=gnupg.so"
FILEPATH="/etc/php/7.0/cli/php.ini"
sudo sed -i "s?$SEARCH?$REPLACE?" $FILEPATH

If you need to add it for php in Apache, then also run:

FILEPATH="/etc/php/7.0/apache2/php.ini"
sudo sed -i "s?$SEARCH?$REPLACE?" $FILEPATH
Last updated: 26th February 2021
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch