Table of Contents

How to install PHP 7 on LiteSpeed Web Server

PHP 7.0.0 Alpha 1 has been released as of 06/12/2015. It marks the beginning of the PHP 7 major series, which is up to two times faster than PHP 5.6. It is not recommended for production yet but the GA version is scheduled to be released by the end of 2015. If you can't wait to test out this “through the roof performance” increase, you can certainly try it out right now. PHP 7 RPMs have already been added to the LiteSpeed Repository. You can either install the RPMs through the LiteSpeed Repository, the Remi Repository, or compile PHP 7 using the “--with-litespeed” configuration option. PHP 7 support has been added to the LSAPI code, has been included in the PHP 7 main branch in Git for a while, and certainly is in the PHP 7.0.0 Alpha 1 release package (though it may be still be showed as LSAPI 6.7 instead of 6.8).

This wiki will guide you through all steps necessary to install PHP 7 on LiteSpeed Web Server.

Install PHP 7 through the LiteSpeed Repository

PHP 7 Alpha 1 RPMs have been added to our repository for CentOS 5/6/7 and RHEL 5/6/7 users. Installing PHP 7 from RPMs will be much faster than compiling yourself.

Add the EPEL Repository

yum install epel-release

Add the LiteSpeed Repository

Use the following commands to add one of our repositories:

CentOS 5:

rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el5.noarch.rpm

CentOS 6:

rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el6.noarch.rpm

CentOS 7:

rpm -ivh http://rpms.litespeedtech.com/centos/litespeed-repo-1.1-1.el7.noarch.rpm

Install PHP RPMs

You can search available RPM packages by using:

yum search lsphp70

Install packages to suit your needs, for example:

yum install lsphp70 lsphp70-common lsphp70-gd lsphp70-process lsphp70-mbstring lsphp70-mysqlnd lsphp70-xml lsphp70-mcrypt lsphp70-pdo lsphp70-imap 

RPMs install lsphp70 to a default directory(/usr/local/lsws/lsphp70/) and the binary file is located in (/usr/local/lsws/lsphp70/bin/lsphp).

Create external LSAPI app pointing to PHP 7

Navigate to WebAdmin console > Server > External App and click “Add”. Then select “LSAPI App” from drop down menu and click “Next”.

Now set your PHP 7 configuration. The following is an example of a typical setting, make sure you set the PHP binary path to the right location: set “command” to “$SERVER_ROOT/lsphp70/bin/lsphp”; the rest of configurations can be adjusted according to your situation.

Name: lsphp70
Address:uds://tmp/lshttpd/lsphp70.sock
Max Connections: 35
Environment: PHP_LSAPI_MAX_REQUESTS=500
             PHP_LSAPI_CHILDREN=35
Initial Request Timeout (secs): 60
Retry Timeout : 0
Response Buffering: no
Start By Server: yes
Command: $SERVER_ROOT/lsphp70/bin/lsphp
Back Log: 100
Instances: 1
Memory Soft Limit (bytes): 2047M
Memory Hard Limit (bytes):2047M
Process Soft Limit: 400
Process Hard Limit: 500

If you prefer using the command line instead of the GUI tool, you can edit the LSWS configuration file (usually /usr/local/lsws/conf/httpd_config.xml) by adding the following to the <extProcessorList>… </extProcessorList> section:

<extProcessor>
    <type>lsapi</type>
    <name>lsphp70</name>
    <address>uds://tmp/lshttpd/lsphp70.sock</address>
    <note></note>
    <maxConns>35</maxConns>
    <env>PHP_LSAPI_MAX_REQUESTS=500</env>
    <env>PHP_LSAPI_CHILDREN=35</env>
    <initTimeout>60</initTimeout>
    <retryTimeout>0</retryTimeout>
    <persistConn></persistConn>
    <pcKeepAliveTimeout></pcKeepAliveTimeout>
    <respBuffer>0</respBuffer>
    <autoStart>1</autoStart>
    <path>$SERVER_ROOT/lsphp70/bin/lsphp</path>
    <backlog>100</backlog>
    <instances>1</instances>
    <extUser></extUser>
    <extGroup></extGroup>
    <runOnStartUp></runOnStartUp>
    <extMaxIdleTime></extMaxIdleTime>
    <priority></priority>
    <memSoftLimit>2047M</memSoftLimit>
    <memHardLimit>2047M</memHardLimit>
    <procSoftLimit>400</procSoftLimit>
    <procHardLimit>500</procHardLimit>
  </extProcessor>

Set script handler to PHP 7

Before you set up PHP 7 to handle your PHP applications, please be aware that PHP 7.0.0 is still in the Alpha 1 stage and is not recommended for production yet. We suggest setting this in your test or staging environment first.

Navigate to WebAdmin console > Server > Script Handler, where you might see that the “php” suffix already exists. Click “edit” for “php”, set “Handler Type” to “LiteSpeed LSAPI”, and then set the “Handler Name” to the one you just created. For example “ lsphp 70”. Lastly save the changes.

Again, if you are a command line Guru and prefer to make the changes through the LSWS configuration file, simply edit the httpd_config.xml file and add the following to your server side <scriptHandlerList>… </scriptHandlerList> section:

  <scriptHandler>
    <suffix>php</suffix>
    <type>lsapi</type>
    <handler>lsphp70</handler>
    <note></note>
  </scriptHandler>

Perform a Graceful restart of the server and you're all set. Your applications should now be served by PHP 7.

Check your PHP installation

You can check that your PHP installation is correct by viewing the “phpinfo()” page. The phpinfo() page should show the correct version of PHP as well as LiteSpeed as the server API.

Install PHP 7 through the Remi Repository

PHP 7 can also be installed through the Remi Repository.

Add the EPEL Repository

yum install epel-release

Add the Remi Repository

RHEL7/CentOS 7:

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

RHEL6/CentOS 6:

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

RHEL5/CentOS 5:

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

Install the LiteSpeed package

You should install at least php70-php-litespeed, which includes the PHP 7 binary to be used by LiteSpeed.

yum --enablerepo=remi,remi-test install php70-php-litespeed

Installing for dependencies:

libzip-last, php70-php-common, php70-php-json, php70-php-zip, php70-runtime, scl-utils

The binary is installed to:/opt/remi/php70/root/usr/bin/lsphp and /usr/bin/lsphp70

Installing other PHP packages

You can also install other packages to suit your needs. For example:

yum --enablerepo=remi,remi-test install php70-php-gd php70-php-process php70-php-mbstring php70-php-mysqlnd php70-php-xml php70-php-mcrypt php70-php-pdo php70-php-imap

Create external LSAPI app pointing to PHP 7

Please follow the same steps as those listed in the prior section by the same name to create a server level external LSAPI app, make sure to set the binary path: “Command:” to “/usr/bin/lsphp70”

Set script handler to PHP 7

Follow similar steps to set up a script handler for the PHP 7 binary. Navigate to WebAdmin console > Server > Script Handler. You might see that the “php” suffix already exists. Click “edit” for “php”, set “Handler Type” to “LiteSpeed LSAPI”, and then set “Handler Name” to the one you just created. For example “ lsphp70”. Save the changes and restart LSWS.

Check your PHP installation

You can check that your PHP installation is correct by viewing the “phpinfo()” page. The phpinfo() page should show the correct version of PHP as well as LiteSpeed as the server API.

Install PHP 7 by compiling from source code

You can download the PHP 7 source code from either git or php.net to compile PHP yourself. Updated LSAPI code with PHP 7 support has been included in the PHP 7.0.0 Alpha1 package and git main branch, hence there is no patch required.

Download the PHP 7 source code and unpack it

You can download the most up-to-date source code from git with:

yum install git autoconf
mkdir /home/php7git
cd /home/php7git
git clone https://git.php.net/repository/php-src.git
cd php-src
./buildconf

or download PHP 7.0.0 version Alpha 1

mkdir /home/php7
cd /home/php7
wget  https://downloads.php.net/~ab/php-7.0.0alpha1.tar.gz
tar -zxvf php-7.0.0alpha1.tar.gz
cd php-7.0.0alpha1

Install build requirements

Some packages may be needed for the PHP 7 build:

yum install patch gcc glibc libstdc++ binutils libtool autoconf make bison pam-devel libcap-devel openssl-devel tcp_wrappers-devel bzip2-devel curl-devel db4-devel gmp-devel httpd-devel libstdc++-devel sqlite-devel sqlite2-devel liyuybedit-devel pcre-devel libtool gcc-c++ libtool-ltdl-devel libevent-devel libc-client-devel cyrus-sasl-devel openldap-devel mysql-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel libjpeg-devel libpng-devel freetype-devel libXpm-devel t1lib-devel libmcrypt-devel libtidy-devel freetds-devel aspell-devel  recode-devel enchant-devel firebird-devel gdbm-devel tokyocabinet-devel

Configure, Compile and Install

In the source code folder, run ./configure with “--with-litespeed” and other configuration options. For example:

./configure  '--prefix=/usr/local/lsws/lsphp70' '--with-libdir=lib64' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--with-curl' '--with-openssl' '--with-gettext' '--with-mcrypt' '--enable-mbstring=all' '--enable-mbregex' '--with-png-dir=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--enable-ftp' '--with-imap=/usr' '--with-imap-ssl' '--with-mysqli=/usr/bin/mysql_config' '--enable-pcntl' '--with-freetype-dir=/usr' '--with-pdo-mysql=/usr' '--with-litespeed'

then

make
make install

Create external LSAPI app pointing to PHP 7

Follow the same steps as mentioned above for external LSAPI app and to set the binary path “Command:” to the prefix you set earlier. If you followed the instructions above, it should be “/usr/local/lsws/lsphp70/bin/lsphp”

Set script handler to PHP 7

Follow similar steps to set up the script handler for the PHP 7 binary. Navigate to the WebAdmin console > Server > Script Handler. You might see that the “php” suffix already exists. Click “edit” for “php”, set “Handler Type” to “LiteSpeed LSAPI”, and then set “Handler Name” to the one you just created. For example “ lsphp70”. Save the changes and restart LSWS.

Check your PHP installation

You can check that your PHP installation is correct by viewing the “phpinfo()” page. The phpinfo() page should show the correct version of PHP as well as LiteSpeed as the server API.