-
Notifications
You must be signed in to change notification settings - Fork 2
How to install any PHP modules using PEAR Package Manager
This tutorial is an extension of Install/Uninstall PHP Extensions (pun not intended) for users who do not find the PHP extensions they need under Server > PHP > Install Extensions
or find the module they need in the LiteSpeed repository.
PEAR package manager can also be used to to manage PECL 4 extensions.
$ cd /usr/local/lsws/lsphp74/bin
$ wget http://pear.php.net/go-pear.phar
$ ./lsphp go-pear.phar
then, using zip extension for example, run:
$ /usr/local/lsws/lsphp74/bin/pecl install zip
# install specific version of zip
$ /usr/local/lsws/lsphp74/bin/pecl install zip-1.21.1
In your website create a php file e.g. info.php with the following contents:
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);
?>
Run the file e.g. http://mywebsite.net/info.php
You should expect this result:
If you need to install any other extension find them here and here or run this command:
$ /usr/local/lsws/lsphp74/bin/pecl search zip
For PEAR extensions configure the extension after installation:
UBUNTU
$ sudo echo "extension=imagick.so" >> /usr/local/lsws/lsphp74/etc/php/7.4/mods-available/40-imagick.ini
ALMALINUX
$ sudo echo "extension=imagick.so" >> /usr/local/lsws/lsphp74/etc/php.d/40-imagick.ini
Restart PHP
Option 1: Go to https://SERVER_URL/managephp/installExtensions > Choose the PHP version you installed extensions for > Click on Restart PHP
Option 2: In SSH Terminal run command touch /usr/local/lsws/admin/tmp/.lsphp_restart.txt
&& systemctl restart lsws
Let's install timezonedb extension for PHP 8.1 for example:
$ cd ~
$ apt-get install libmagickwand-dev pkg-config build-essential lsphp81-dev
$ wget -O timezonedb.tar.gz https://github.com/php/pecl-datetime-timezonedb/archive/refs/tags/RELEASE_2022_7.tar.gz
$ tar vxzf timezonedb.tar.gz
$ cd pecl-datetime-timezonedb-RELEASE_2022_7
$ sh rebuild.sh # this runs phpize && ./configure && make clean && make
$ make install
$ echo "extension=timezonedb.so" >> /usr/local/lsws/lsphp81/etc/php/8.1/mods-available/01-timezonedb.ini
$ touch /usr/local/lsws/admin/tmp/.lsphp_restart.txt
$ systemctl restart lsws
$ ls /usr/local/lsws/lsphp81/lib/php/20210902/
# do you see timezonedb.so