This is an old revision of the document!


How To Install a PECL Extension For LSPHP?

You may need a certain PHP PECL extension to get your application working. The usual method of /usr/local/lsws/lsphp5x/bin/pecl install extention-name may not work as there is no lsphp5x-pear package available at the time of this writing.

There are several other ways to get a PHP PECL extension installed:

  • Check the LiteSpeed repository for package availability
  • Compile from Source Code
  • Install the PEAR package manager

If you installed lsphp5x or lsphp7x through the LiteSpeed CentOS repository, you can check if the PECL extension is already available in the repository.

For example, to check imagick's availability in lsphp55, you would enter the following in to the terminal:

yum search lsphp55-pecl-imagick

or

yum list lsphp55-pecl*

If the extension is there, simply yum install and your all set.

If the extension is not in our repository, you can send a request to support@litespeedtech.com requesting it's inclusion and we will evaluate the possibility off adding it.

A quicker method is to also build the required PECL extension from source code yourself.

Let's look at an example with the PECL imagick extension. This extension is not available in the LiteSpeed repository at the time of this writing. You can perform the following steps to build it for lsphp55 yourself.

yum install epel-release
yum install gcc gcc-c++ make autoconf glibc rcs #(setup build environment)
yum install lsphp55-devel #( need devel package) 
yum install ImageMagick-devel  # need ImageMagick-devel
wget https://pecl.php.net/get/imagick-3.1.2.tgz
tar -zxvf imagick-3.1.2.tgz
cd imagick-3.1.2
/usr/local/lsws/lsphp55/bin/phpize
./configure --with-imagick=/usr/local/lsws/lsphp55 --with-php-config=/usr/local/lsws/lsphp55/bin/php-config
make
make install

The imagick extension is now installed to the following directories:

Installing shared extensions:     /usr/local/lsws/lsphp55/lib64/php/modules/
Installing header files:          /usr/local/lsws/lsphp55/include/php/

Modify the php.ini file by adding the following and restart LSWS.

extension = imagick.so

Check the phpinfo.php page and you should see imagick enabled.

You can do similar with other LSPHP versions and PECL extensions.

You can also install the PEAR package manager to manage PECL extensions.

cd /usr/local/lsws/lsphp55/bin
wget http://pear.php.net/go-pear.phar
./lsphp go-pear.phar

There is a bug in PECL scripts when installed this way, which omits dynamic PHP modules including XML. You can patch it by simply editing it to remove the ā€œ-nā€ cauisng the problem:

vi /usr/local/lsws/lsphp55/bin/pecl
  

Remove ā€œ-nā€ from the following:

exec $PHP -C -n -q $INCARG -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"
  

then run

/usr/local/lsws/lsphp55/bin/pecl install imagick

imagick.so should now be installed to the correct location.

chmod a+x /usr/local/lsws/lsphp55/lib64/php/modules/imagick.so

Lastly, edit php.ini to enable extension and restart LSWS.

  • Admin
  • Last modified: 2015/11/10 14:05
  • by Michael Alegre