[Solved] How to check in PHP CLI if LSWS is installed


Well-Known Member
I want to check in PHP CLI if LSWS is used or installed, but in PHP CLI there is no environment variable about SERVER_SOFTWARE available, because in CLI the PHP build-in webserver is running.

Any Ideas?


Well-Known Member
If PHP is executed in PHP CLI environment LSWS is not in use. PHP uses built-in webserver in PHP CLI but in this environment there are not all variables available.

Run php -i or php -m in PHP CLI to verify


Well-Known Member
Staff member
I believe the way to detect web server is to check the litespeed process itself, not through "php-i"

Jon K

Staff member
You cannot see if LSWS is being used via the command line. It will only be used when using a browser with litespeed. When using via the CLI, it just uses the CLI interface no need for LiteSpeed.

If you need to check it via command line you can curl a phpinfo page and check for server_software there.


Well-Known Member
For everybody who needs a solution to check in PHP CLI if LSWS is running.

$url = 'https://www.example.com';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$result = curl_exec($ch);

$lcHeaders = [];
$trim_result = rtrim($result);
$lcData = explode("\n", $trim_result);
$lcHeaders['status:'] = $lcData[0];

foreach ($lcData as $lcPart) {
    $lcMiddle = explode(":", $lcPart, 2);
    if (!isset($lcMiddle[1])) {
        $lcMiddle[1] = null;
    $lcHeaders[trim($lcMiddle[0])] = trim($lcMiddle[1]);

if (isset($lcHeaders["Server"]) && $lcHeaders["Server"] == 'LiteSpeed') {
    echo 'LiteSpeed webserver is running';
Last edited: