Help:Default PHP Settings

From OpenLiteSpeed
Jump to: navigation, search

PHP is fully supported by OpenLiteSpeed out of box. No additional configuration is required. This article will go over how OpenLiteSpeed handle PHP and OpenLiteSpeed's default PHP settings.

PHP is not embedded in OpenLiteSpeed as it commonly is in Apache. OpenLiteSpeed delegates PHP execution to external PHP executables (external applications). This system allows for better security, stability, and handling of multiple connections. OpenLiteSpeed can use two PHP SAPI interfaces to communicate with the external applications: LiteSpeed SAPI (LSAPI) or FastCGI SAPI (FCGI SAPI). LSAPI is recommended. LSAPI is built specifically for use with OpenLiteSpeed and LiteSpeed Web Server. It is faster and contains more features than FCGI SAPI.

Components for PHP support

  1. A PHP external application
  2. A script handler set to the PHP external application.

As stated above, OpenLiteSpeed delegates PHP scripts to PHP external applications. This external application must be specified and set up in OpenLiteSpeed's configurations. OpenLiteSpeed determines which files should go to which applications by mapping suffixes using a script handler. This script handler must also be set up so OpenLiteSpeed will know to send PHP scripts to the PHP external application. OpenLiteSpeed has a server-level PHP external application and script handler by default. These settings are explored below.

The default PHP setup

OpenLiteSpeed comes with a PHP script handler, a PHP external application configured, and a pre-built PHP 5.3.25 executable (as of this writing) with minimum features. The external application and script handler are set at the server level. First, we will examine these default configurations:

The default lsphp5 external application

The default PHP external application is called "lsphp5".

WebAdmin console => Configuration => Server => External App => lsphp5 Lsphp5.png

The PHP executable's location is listed under the Command setting.

Lsphp5-settings.png

The default lsphp5 script handler

The default PHP script handler maps .php files to the external application "lsphp5".

WebAdmin Console => Configuration => Server => Script Handler => lsphp5

By setting its Suffix setting to "php", all files with the suffix .php should be sent to the external application specified in this script handler: lsphp5.

Lsphp5-scripthandler.png

The default PHP executable

We saw before (in the External Application settings) that the PHP executable was located at $SERVER_ROOT/fcgi-bin/lsphp5. If we go into our command line, though, we find that this is not exactly true. There is a symlink from lsphp5 to a file in the same directory called lsphp. lsphp is the real PHP executable. This symlinking is done so that we don't have to overwrite old PHP executables when we build a new PHP executable. When we build a new PHP executable, we create a new file with a new name. Having multiple different files allows us to easily use different versions of PHP and revert back to older versions of PHP if we don't like a new one we've built. For more on building a custom PHP, see our article on the subject.

If you run the ./lsphp5 -v command, you can see what version lsphp5 currently is.

Lsphp5-binary.png