PHP Extensions¶
Warning
If you are using a control panel then the following document will not be helpful. We honor how the control panels handle PHP Extensions.
- cPanel: EasyApache 4
- Plesk: PHP Settings
- CloudLinux: PHP Selector
- DirectAdmin: CustomBuild 2.0
PECL¶
Overview¶
PECL is a repository for PHP extensions, providing a directory of all known extensions and hosting facilities for downloading and developing PHP extensions. You may need a certain PHP PECL extension to get the application working. This guide explains how to install PECL extensions for native LSWS installs. For cPanel installs please refer to this ‘PHP PECL’ article.
There are several ways to get a PHP PECL extension installed:
- LiteSpeed Repository
- The PEAR Package Manager
- Source Code
Important
If you have not already set up our repository on your system, you can learn how to do that in our ‘Getting Started | PHP’ article. Please be sure to do this before proceeding. Also be mindful that there are some differences in CentOS and Debian/Ubuntu’s package names so that they are more in line with their individual distribution’s packages.
Install¶
LiteSpeed Repository¶
We offer some of the more popular PECL extensions right in our own CentOS or Debian/Ubuntu repositories.
The extensions we currently offer are:
- APCu
- Igbinary
- Imagick
- Memcached
- Msgpack
- Redis
If the extension is not in our repository, you can send a request to support@litespeedtech.com requesting its inclusion and we will evaluate the possibility of adding it.
To install a PECL extension via a repository, type one the following commands into a terminal, depending on your distribution:
$ sudo yum install lsphpXX-pecl-PECL_NAME
$ sudo dnf install lsphpXX-pecl-PECL_NAME
$ sudo apt install lsphpXX-PECL_NAME
Info
Be sure to replace XX with the specific PHP version and PECL_NAME with the PECL extension you wish to install.
Once completed, please skip ahead to the Finish section.
The PEAR Package Manager¶
Another way to install a PECL extension is by using PECL, which is supplied by PEAR.
Install PEAR/PECL by running one of the following inside of a terminal:
$ sudo yum install lsphpXX-pear
$ sudo dnf install lsphpXX-pear
$ sudo apt install lsphpXX-pear
$ sudo cd /usr/local/lsws/lsphpXX/bin
$ wget http://pear.php.net/go-pear.phar
$ sudo ./php go-pear.phar
$ sed -i -e 's/-C -n/-C/g' ./pecl
Install/Set up the necessary PECL extension by running the following commands inside of a terminal:
$ sudo /usr/local/lsws/lsphpXX/bin/pecl install PECL_NAME
Once completed, please skip ahead to the Configure section.
Source Code¶
The PECL extensions can also be compiled and installed from source code.
In the following examples we will install the PECL extension, Imagick, for LSPHPXX. We will install the necessary packages first, and then do the compilation.
Type the following code blocks for your specific distribution into the terminal in order to install the necessary build packages:
$ sudo yum install epel-release # Installs the Extra Packages for Enterprise Linux Repo
$ sudo yum install gcc gcc-c++ make autoconf glibc rcs # Installs compilation needed packages
$ sudo yum install lsphpXX-devel # Installs the LSPHP devel package
$ sudo yum install ImageMagick-devel # Installs the ImageMagick-devel package
$ sudo dnf install epel-release # Installs the Extra Packages for Enterprise Linux Repo
$ sudo dnf install gcc gcc-c++ make autoconf glibc rcs # Installs compilation needed packages
$ sudo dnf install lsphpXX-devel # Installs the LSPHP devel package
$ sudo dnf install ImageMagick-devel # Installs the ImageMagick-devel package
$ sudo apt-get install libmagickwand-dev pkg-config build-essential # Installs compilation needed packages
$ sudo apt-get install lsphpXX-dev # Installs the LSPHP dev package
After the build packages are installed the next step is to compile Imagick. Run the following into a terminal:
$ wget https://pecl.php.net/get/imagick-3.7.0.tgz
$ tar -zxvf imagick-3.7.0.tgz
$ cd imagick-3.7.0
$ sudo /usr/local/lsws/lsphpXX/bin/phpize
$ ./configure --with-imagick=/usr/local/lsws/lsphpXX --with-php-config=/usr/local/lsws/lsphpXX/bin/php-config
$ make
$ sudo make install
Once completed, please skip ahead to the Configure section.
Configure¶
The imagick extension is now installed to the following directories:
Installing shared extensions: /usr/local/lsws/lsphpXX/lib64/php/modules/
Installing header files: /usr/local/lsws/lsphpXX/include/php/
Installing shared extensions: /usr/local/lsws/lsphpXX/lib/php/XXXXXXXX/
Installing header files: /usr/local/lsws/lsphpXX/include/php/
Next, load the PECL extension via a .ini file.
$ sudo echo "extension=imagick.so" >> /usr/local/lsws/lsphpXX/etc/php.d/40-imagick.ini
$ sudo echo "extension=imagick.so" >> /usr/local/lsws/lsphpXX/etc/php/X.X/mods-available/40-imagick.ini
Finish¶
Once everything is installed and loaded, restart PHP and the web server.
$ sudo touch /usr/local/lsws/admin/tmp/.lsphp_restart.txt
$ sudo systemctl restart lsws
When checking a phpinfo.php page it should now show the PECL extension, Imagick, as enabled.
Info
You can follow a similar procedure with other LSPHP versions and PECL extensions.
Ioncube¶
ionCube Loader is sometimes needed when using encoded and secure PHP files. This section will show you how to enable it for LSPHP.
Repository¶
Important
If you have not already set up our repository on your system you can find out how to do that in our ‘Getting Started | PHP’ article. Please be sure to do this before proceeding. Also, be mindful there are some differences in CentOS and Debian/Ubuntu’s package names so that they are more in line with their individual distribution’s packages.
To install ionCube via the repository run the following in a command prompt:
$ sudo yum install lsphpXX-ioncube
$ sudo dnf install lsphpXX-ioncube
$ sudo apt install lsphpXX-ioncube
Manual¶
-
Download ionCube by running:
$ wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
-
Extract the package by running:
$ tar -xf ioncube_loaders_lin_x86-64.tar.gz
-
Move the needed .so file by running:
$ sudo cp ioncube/ioncube_loader_lin_X.X.so /usr/local/lsws/lsphpXX/lib64/php/modules/ioncube.so
$ sudo cp ioncube/ioncube_loader_lin_X.X.so /usr/local/lsws/lsphpXX/lib/php/XXXXXXXX/ioncube.so
-
Now, enable the extension by running:
$ sudo echo "extension=ioncube.so" >> /usr/local/lsws/lsphpXX/etc/php.d/01-imagick.ini
$ sudo echo "extension=ioncube.so" >> /usr/local/lsws/lsphpXX/etc/php/X.X/mods-available/01-imagick.ini
-
Restart PHP in order for the changes to take affect.
$ sudo touch /usr/local/lsws/admin/tmp/.lsphp_restart.txt $ sudo systemctl restart lsws
Note
Be sure to replace XX and X.X with the version of PHP you want to install ionCube to.