How to Install GnuPG PHP extension via PECL for cPanel/Cyberpanel

H

In this guide, we will show you how to rapidly install GnuPG PECL PHP Extension for PHP5.x and PHP7.x series for cPanel and Cyberpanel.

Installing GnuPG on PHP 5.x and 7.0, 7.1, 7.2, 7.3 can be done via the below commands for cPanel Servers. It is a very similar process for Cyberpanel so skip to the bottom to see that process.

This is the all in one command set to do this for cPanel

yum install -y gnupg gpgme gpgme-devel
for PHP in $(ls -h /opt/cpanel |grep ea-php); do printf '\n' |/opt/cpanel/$PHP/root/usr/bin/pecl install gnupg; done
service httpd restart;

How to check for this after installation.

for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do echo "PHP $phpver" ; /opt/cpanel/ea-php$phpver/root/usr/bin/php -m |grep -E 'gnupg'; echo ""; done;

This is the Guide for Cyberpanel

Here is how we can install the PECL extension for all PHP 5.x and 7.x versions for Cyberpanel lsphp.

yum install -y gnupg gpgme gpgme-devel
for version in $(ls /usr/local/lsws|grep lsphp); do /usr/local/lsws/${version}/bin/pecl channel-update pecl.php.net; done
Extension="gnupg";for version in $(ls /usr/local/lsws|grep lsphp); do printf '\n' |/usr/local/lsws/${version}/bin/pecl install ${Extension} && echo "extension=${Extension}.so" >> /usr/local/lsws/${version}/etc/php.d/zzzzzzz-pecl.ini; done; systemctl restart lsws||service lsws restart; systemctl status lsws||service lsws status;

Please note the beauty of the above command is that it automatically adds the PHP extension to the ini file for each version for its “zzzzzzz-pecl.ini”. The warning about the “You should add “extension=oauth.so” to php.ini” can be ignored. As this script handles it for you. If you do it manually without this script then that would be applicable.

Pecl update all Versions

for version in $(ls /usr/local/lsws|grep lsphp); do /usr/local/lsws/${version}/bin/pecl channel-update pecl.php.net; done
[root@server ~]# for version in $(ls /usr/local/lsws|grep lsphp); do /usr/local/lsws/${version}/bin/pecl channel-update pecl.php.net; done
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
Updating channel "pecl.php.net"
Update of Channel "pecl.php.net" succeeded
[root@server ~]#

This command lets you check to see if all PHP versions show the module is installed.

for phpver in $(ls -1 /usr/local/lsws/ |grep lsphp | sed 's/lsphp//g') ; do echo ""; echo "LSPHP $phpver" ; /usr/local/lsws/lsphp$phpver/bin/php -m | grep -i gnupg; done
[root@server:~]# for phpver in $(ls -1 /usr/local/lsws/ |grep lsphp | sed 's/lsphp//g') ; do echo ""; echo "LSPHP $phpver" ; /usr/local/lsws/lsphp$phpver/bin/php -m | grep -i gnupg; done

LSPHP 53
gnupg

LSPHP 54
gnupg

LSPHP 55
gnupg

LSPHP 56
gnupg

LSPHP 70
gnupg

LSPHP 71
gnupg

LSPHP 72
gnupg

LSPHP 73
gnupg

LSPHP 74
gnupg
[root@server:~]# 

Some screenshots of this on the Cyberpanel Server installation process.