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

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

Installing OAuth 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 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

for version in $(ls /opt/cpanel|grep ea-php); do /opt/cpanel/${version}/root/usr/bin/pecl channel-update pecl.php.net; done;
for PHP5 in $(ls -h /opt/cpanel |grep ea-php5); do /opt/cpanel/$PHP5/root/usr/bin/pecl install oauth-1.2.3; done
for PHP7 in $(ls -h /opt/cpanel |grep ea-php7); do /opt/cpanel/$PHP7/root/usr/bin/pecl install oauth; done

If no errors you will want to restart the HTTP service after modules are installed to activate them.

systemctl restart httpd||service httpd restart 

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

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 -iE 'oauth'; echo ""; done

This is a breakdown of what each line does for the curious.

The first command updates pecl for all PHP versions installed.

for version in $(ls /opt/cpanel|grep ea-php); do /opt/cpanel/${version}/root/usr/bin/pecl channel-update pecl.php.net; done;

The second command installs oauth-1.2.3 which is the latest version that supports the PHP 5.x series.

for PHP5 in $(ls -h /opt/cpanel |grep ea-php5); do /opt/cpanel/$PHP5/root/usr/bin/pecl install oauth-1.2.3; done

The third command installs oauth latest version that supports the PHP 7.x series.

for PHP7 in $(ls -h /opt/cpanel |grep ea-php7); do /opt/cpanel/$PHP7/root/usr/bin/pecl install oauth; 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 lsphp*-devel make gcc glibc-devel zlib-devel;
for PHP5 in $(ls /usr/local/lsws|grep lsphp5); do /usr/local/lsws/$PHP5/bin/pecl install oauth-1.2.3 && echo "extension=oauth.so" >> /usr/local/lsws/$PHP5/etc/php.d/zzzzzzz-pecl.ini; done;
for PHP7 in $(ls /usr/local/lsws|grep lsphp7); do /usr/local/lsws/$PHP7/bin/pecl install oauth && echo "extension=oauth.so" >> /usr/local/lsws/$PHP7/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 to 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 oauth; 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 oauth; done

LSPHP 53
OAuth

LSPHP 54
OAuth

LSPHP 55
OAuth

LSPHP 56
OAuth

LSPHP 70
OAuth

LSPHP 71
OAuth

LSPHP 72
OAuth

LSPHP 73
OAuth

LSPHP 74
OAuth
[root@server ~]#

Some screenshots of this on the Cyberpanel Server installation process.