By default virtual hosts inherit the version of PHP that is set at the server level. You may wish to use a different PHP version for certain virtual hosts. Follow the steps below to set up virtual-host-level PHP. Here we will use the PHP version 7.4 as an example.
Install PHP 7.4 and commonly used PHP extensions:
apt-get install lsphp74 lsphp74-common lsphp74-curl lsphp74-imagick lsphp74-imap lsphp74-json lsphp74-memcached lsphp74-mysql lsphp74-opcache lsphp74-redis -y
Navigate to WebAdmin console > Server Configuration > External App > Add > Type > LiteSpeed SAPI App to set up a server-level external application. Set the following values:
- Name:
lsphp74
- Address:
uds://tmp/lshttpd/lsphp74.sock
- Max Connections:
35
- Environment:
LSAPI_AVOID_FORK=200M
- Initial Request Timeout (secs):
60
- Retry Timeout (secs):
0
- Command:
/usr/local/lsws/lsphp74/bin/lsphp
- Instances:
1
Navigate to WebAdmin console > Virtual Hosts > your vhost > Script Handler > Add to add a virtual-host-level PHP handler. Set the following values:
- Suffixes:
php
- Handler Type:
LiteSpeed SAPI
- Handler Name:
[Server Level]:lsphp74
OpenLiteSpeed come with php detached mode by default, so need to restart php with command killall -9 lsphp
to make settings take effect.