Default PHP Settings

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

 

PHP is fully supported by OpenLiteSpeed out of box. No additional configuration is required. However the default binary installed(/usr/local/lsws/fcgi-bin/lsphp) is a minimum build for testing use and can not be used for real applications. This article is not intended to provide instruction on how to install new binary, however it 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.6 executable (as of this writing) with minimum features. The external application and script handler are set at the server level. We will also list the default php.ini locations but first, we will examine these default server configurations:

The default lsphp external application

The default PHP external application is called “lsphp”.

WebAdmin console => Server Configuration => External App => lsphp

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

The default lsphp script handler

The default PHP script handler maps .php files to the external application “lsphp”.

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

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: lsphp.

The default PHP executable

We saw before (in the External Application settings) that the PHP executable was located at $SERVER_ROOT/fcgi-bin/lsphp7. If we go into our command line, though, we find that this is not exactly true. There is a symlink from lsphp7 to a file in the same directory called lsphplsphp 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 ./lsphp7 -v command, you can see what version lsphp7 currently is.

The default php.ini locations

The default PHP configuration file (php.ini) for each lsphp version installed can be found in a subdirectory corresponding to the version of LSAPI that is being used. So for PHP with LSAPI 7.3 then lsphp73 would be the directory to find it under as below:

/usr/local/lsws/lsphp73/etc/php.ini
/usr/local/lsws/lsphp72/etc/php.ini
/usr/local/lsws/lsphp71/etc/php.ini
/usr/local/lsws/lsphp70/etc/php.ini
/usr/local/lsws/lsphp56/etc/php.ini
/usr/local/lsws/lsphp55/etc/php.ini
/usr/local/lsws/lsphp54/etc/php.ini
/usr/local/lsws/lsphp53/etc/php.ini