Help:PHP FCGI Setup
Fast CGI (FCGI) SAPI is supported in OpenLiteSpeed as a a way to communicate with PHP external applications. Our tests show LSAPI to be a faster method of communicating with PHP external applications. Some people, though, may still be interested in building PHP with FCGI SAPI. Here we provide the procedure for doing so.
FCGI SAPI external applications can be set up at either the server level or the virtual host level. Server-level external applications can be shared by all virtual hosts.
Download the PHP source package
For this guide, we will download the latest PHP (5.5.0) package. This can be done from either your browser or the command line.
You can put the PHP package anywhere you like. We recommend using the
$SERVER_ROOT/phpbuild directory for ease of use.
[root@localhost phpbuild]# wget http://us1.php.net/distributions/php-5.5.0.tar.bz2 --2013-07-16 06:28:22-- http://us1.php.net/distributions/php-5.5.0.tar.bz2 Resolving us1.php.net... 188.8.131.52 Connecting to us1.php.net|184.108.40.206|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 12256814 (12M) [application/octet-stream] Saving to: `php-5.5.0.tar.bz2' 100%[=================================================>] 12,256,814 6.33M/s in 1.8s 2013-07-16 06:28:24 (6.33 MB/s) - `php-5.5.0.tar.bz2' saved [12256814/12256814] [root@localhost phpbuild]#
Unpack the PHP package
[root@localhost phpbuild]# tar jxf php-5.5.0.tar.bz2 [root@localhost phpbuild]# cd php-5.5.0 [root@localhost php-5.5.0]#
Compile PHP with FCGI related options:
(Again, the prefix we are using,
$SERVER_ROOT/fcgiphp5, is not required. The PHP build can be installed anywhere that OpenLiteSpeed will have access to it. This just seemed the easiest place to put it.)
[root@localhost php-5.5.0]# ./configure --prefix=/usr/local/lsws/fcgiphp5 --with-mysqli --with-zlib \ --with-gd --enable-shmop --enable-sockets --enable-sysvsem --enable-sysvshm \ --enable-mbstring --with-iconv [root@localhost php-5.5.0]# make && make install
Create an FCGI SAPI external application
(WebAdmin console => Configuration => Server => External App => Add => Type="FCGI")
You must set the Command setting to the location of your PHP binary.
Other settings to pay attention to include Memory Limit (soft/hard), Process Limit (soft/hard), Back Log, and Instances. Suggestions for settings values can be found in the screenshot below:
Create a script handler to map files to the FCGI external application
(WebAdmin console => Configuration => Server => Script Handler => Add)
A script handler will tell OpenLiteSpeed which files (generally those with the suffix .php) to send to the Fast CGI external application just created.
Graceful restart to apply changes
Point your browser to your phpinfo page to check your PHP settings. Under Server API, it should say "CGI/FastCGI"