"Fossies" - the Fresh Open Source Software Archive

Member "php-7.4.1/sapi/litespeed/README.md" (17 Dec 2019, 8595 Bytes) of package /linux/www/php-7.4.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field. See also the last Fossies "Diffs" side-by-side code changes report for "README.md": 7.3.12_vs_7.4.0.

Introduction

LiteSpeed SAPI module is a dedicated interface for PHP integration with LiteSpeed Web Server. LiteSpeed SAPI has similar architecture to the FastCGI SAPI with there major enhancements: better performance, dynamic spawning and PHP configuration modification through web server configuration and .htaccess files.

A simple benchmark test (“hello world”) shows that PHP with LiteSpeed SAPI has 30% better performance over PHP with FastCGI SAPI, which is nearly twice the performance that Apache mod_php can deliver.

A major drawback of FastCGI PHP comparing to Apache mod_php is lacking the flexibilities in PHP configurations. PHP configurations cannot be changed at runtime via configuration files like .htaccess files or web server’s virtual host configuration. In shared hosting environment, each hosting account will has its own open_basedir overridden in server configuration to enhance server security when mod_php is used. Usually, FastCGI PHP is not an option in shared hosting environment due to lacking of this flexibility. LiteSpeed SAPI is carefully designed to address this issue. PHP configurations can be modified the same way as that in mod_php with the same configuration directives.

PHP with LiteSpeed SAPI is highly recommended over FastCGI PHP for PHP scripting with LiteSpeed web server.

Building PHP with LiteSpeed SAPI

You need to add --enable-litespeed to the configure command to build PHP with LiteSpeed SAPI, all other SAPI related configure options should be removed.

For example:

./configure --enable-litespeed
make

You should find an executable called lsphp under sapi/litespeed/ directory after the compilation succeeds. Copy it to lsws/fcgi-bin/lsphp or wherever you prefer, if LiteSpeed web server has been configured to run PHP with LiteSpeed SAPI already, you just need to overwrite the old executable with this one and you are all set.

Start PHP from command line

Usually, lsphp is managed by LiteSpeed web server in a single server installation. lsphp can be used in clustered environment with one LiteSpeed web server at the front, load balancing lsphp processes running on multiple backend servers. In such environment, lsphp can be start manually from command with option -b <socket_address>, socket address can be IPv4, IPv6 or Unix Domain Socket address.

For example:

./lsphp -b [::]:3000

have lsphp bind to port 3000 on all IPv4 and IPv6 address,

./lsphp -b *:3000

have lsphp bind to port 300 on all IPv4 address,

./lsphp -b 192.168.0.2:3000

have lsphp bind to address 192.168.0.2:3000,

./lsphp -b /tmp/lsphp_manual.sock

have lsphp accept request on Unix domain socket /tmp/lsphp_manual.sock.

Using LiteSpeed PHP with LiteSpeed Web Server

Detailed information about how to configure LiteSpeed web server with PHP support is available from LiteSpeed website.

Usually, PHP support has been configured out of box, you don’t need to change it unless you want to change PHP interface from FastCGI to LiteSpeed SAPI or vice versa.

Brief instructions are as follow:

  1. Login to web administration interface, go to ‘Server’->‘Ext App’ tab, add an external application of type “LSAPI app”, “Command” should be set to a shell command that executes the PHP binary you just built. “Instances” should be set to “1”. Add “LSAPI_CHILDREN” environment variable to match the value of “Max Connections”. More tunable environment variable described below can be added.

  2. Go to ‘Server’->‘Script Handler’ tab, add a script handler configuration: set ‘suffix’ to ‘php’, ‘Handler Type’ to ‘LiteSpeed API’, ‘Handler Name’ should be the name of external application just defined.

  3. Click ‘Apply Changes’ link on the top left of the page, then click ‘graceful restart’. Now PHP is running with LiteSpeed SAPI.

Tunings

There are a few environment variables that can be tweaked to control the behavior of LSAPI application.

Compatibility with Apache mod_php

LSAPI PHP supports PHP configuration overridden via web server configuration as well as .htaccess.

Since 4.0 release apache_response_headers function is supported.

Contact

For support questions, please post to the free support forum:

For bug report, please send bug report to bug [at] litespeedtech.com.