Install PHP through repositories

How Can We Help?
< Back
You are here:
Print

Installing PHP with LiteSpeed SAPI from a repository is much faster and recommended way. PHP for LiteSpeed (LSAPI) is available in two repositories — Remi Repository(CentOS) and our own LiteSpeed Repository(CentOS/Debian/Ubuntu). Choose the repository that best fits your needs.

Installing PHP from the LiteSpeed Repository

You can install PHP from LiteSpeed Repository

  • PHP 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2
  • CentOS and RHEL 6/7/8/9, Ubuntu/Debian
  • Contains most up-to-date versions of LSAPI. (Do not have to wait for a new PHP version to be released.)
  • Easily install multiple versions of PHP (by default installed to different locations).
  • Contains all frequently used PHP packages.
  • Contains multiple possible MySQL support packages (via native driver or client library).
  • Contains multiple opcode caching options: APC, Xcache, Zend Opcache.

For CentOS/RHEL Users

Add EPEL Repository

yum install epel-release

Add LiteSpeed Repository

Use the following commands to add our CentOS/AlmaLinux/RockyLinux repositories:

sudo wget -O - https://repo.litespeed.sh | sudo bash

For Debian and Ubuntu Users

sudo wget -O - https://repo.litespeed.sh | sudo bash

Install PHP

Once you’ve added our repository, you can use yum to install PHP for LiteSpeed with a variety of modules. The following command will install LSPHP 5.6:

yum install lsphp56 lsphp56-common lsphp56-mysql lsphp56-gd lsphp56-process lsphp56-mbstring lsphp56-xml lsphp56-mcrypt lsphp56-pdo lsphp56-imap lsphp56-soap lsphp56-bcmath

The LiteSpeed Repository automatically installs PHP to /usr/local/lsws/lsphp5x/bin/lsphp where 5x is the version and subversion. Thus PHP 5.6 would be installed to /usr/local/lsws/lsphp56/bin/lsphp.

This allows you to easily install multiple versions of PHP because different versions of PHP are installed to different directories. See our guide to setting up multiple PHPs for further details.

Find all available packages here.

Direct LSWS to the Location of the Installed PHP

As noted above, the LiteSpeed Repository installs PHP to /usr/local/lsws/lsphp5x/bin/lsphp. This is not the place LSWS normally looks for PHP, so we will now need to direct LSWS to look there.

The easiest way to do this is from the command line:

ln -sf /usr/local/lsws/lsphp56/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5

The above command symbolically links the new version of PHP to the place OpenLiteSpeed’s default external application looks for PHP.

If you are using external applications other than OpenLiteSpeed’s default external application “lsphp5,” see our guide to setting up multiple PHPs for further details.

Check Your PHP Installation

You can check that your PHP installation is correct by creating & then viewing a phpinfo() page. The phpinfo() page should show the correct version of PHP and LiteSpeed as the Server API. You can verify the location of the php.ini configuration file this way as well.

Create:

You would create a PHP file with the following contents in your document root or another directory that is configured for web access:

<?php
phpinfo( );
?>

You could name it info.php but since it exposes lots of information that could make it easier for hackers then you should delete it as soon as its no longer needed and consider naming it something hard to guess, just as long as it has the .php extension.

View:

Type the URI for the new file into your web browser:

 

PHP packages for common applications

WordPress
yum install lsphp81 lsphp81-common lsphp81-bcmath lsphp81-intl lsphp81-mysqlnd lsphp81-opcache lsphp81-pdo lsphp81-pecl-imagick lsphp81-pecl-memcached lsphp81-pecl-redis lsphp81-sodium lsphp81-xml lsphp81-zip
Magento
yum install lsphp81 lsphp81-common lsphp81-bcmath lsphp81-gd lsphp81-intl lsphp81-mbstring lsphp81-mysqlnd lsphp81-opcache lsphp81-pdo lsphp81-soap lsphp81-sodium lsphp81-xml lsphp81-zip
Joomla
yum install lsphp81 lsphp81-common lsphp81-bcmath lsphp81-gd lsphp81-intl lsphp81-mbstring lsphp81-mysqlnd lsphp81-opcache lsphp81-pdo lsphp81-pecl-memcached lsphp81-pecl-redis lsphp81-soap lsphp81-sodium lsphp81-xml lsphp81-zip
Drupal
yum install lsphp81 lsphp81-common lsphp81-bcmath lsphp81-gd lsphp81-intl lsphp81-mbstring lsphp81-mysqlnd lsphp81-opcache lsphp81-pdo lsphp81-pecl-memcached lsphp81-pecl-redis lsphp81-soap lsphp81-sodium lsphp81-xml lsphp81-zip

Installing PHP from Remi Repo

You can install PHP from Les RPM de Remi (Remi Repository):

  • PHP 5.6, 7.0, 7.1, 7.2. 7.3, 7.4, 8.0, 8.1, 8.2
  • CentOS and RHEL 6/7/8/9
  • Allows installation of multiple builds of PHP through SCL.
  • Contains packages for many rare use cases as well as more common use cases.

The following steps can be used to install PHP 5.5 with LSAPI on CentOS 6. Consult the Remi Repository site for installation with other builds.

Add the Repositories

Remi Repository requires the EPEL repository as well.

 wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
 wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
 rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

Enable Remi Repo

Open the Remi repo file:

vi /etc/yum.repos.d/remi.repo

In the [remi-php55] section, set enabled to 1.

Note: The [remi-php55] section is for PHP 5.5. The [remi-php] section is for PHP 5.4 and the [remi-php56] section is for PHP 5.6.

Install PHP for OpenLiteSpeed from the Repository

Remi’s PHP with LSAPI package is called “php-litespeed”.

yum install php-litespeed

Note: You can, of course, also install any other packages you wish (such as php-opcode).

Direct OpenLiteSpeed to the Location of the Installed PHP

By default, Remi Repo installs PHP with LSAPI to /usr/bin/lsphp. This is not the place OpenLiteSpeed normally looks for PHP, so we will now need to direct OpenLiteSpeed to look there.

The easiest way to do this is from the command line:

ln -sf /usr/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp5

The above command symbolically links the new version of PHP to the place OpenLiteSpeed’s default external application looks for PHP.

If you are using external applications other than OpenLiteSpeed’s default external application “lsphp5,” see our guide to setting up multiple PHPs for further details.

Check Your PHP Installation

You can check that your PHP installation is correct by creating & then viewing a phpinfo() page. The phpinfo() page should show the correct version of PHP and LiteSpeed as the Server API. You can verify the location of the php.ini configuration file this way as well.

Create:

You would create a PHP file with the following contents in your document root or another directory that is configured for web access:

<?php
phpinfo( );
?>

You could name it info.php but since it exposes lots of information that could make it easier for hackers then you should delete it as soon as its no longer needed and consider naming it something hard to guess, just as long as it has the .php extension.

View:

Type the URI for the new file into your web browser:

For Ubuntu/Debian Users

Please refer to this wiki, which is written for LiteSpeed Enterprise version but it is applicable to OpenLiteSpeed as well.