From c4b88520d104e58b7be9ab49b8d4657c9a188a4e Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 18 Jun 2025 00:08:40 +0800 Subject: [PATCH] fix llsmp directories --- scripts/check_litespeed.php | 151 ++++++++++++++---------------------- 1 file changed, 59 insertions(+), 92 deletions(-) diff --git a/scripts/check_litespeed.php b/scripts/check_litespeed.php index 59492a5..85fc7a1 100644 --- a/scripts/check_litespeed.php +++ b/scripts/check_litespeed.php @@ -1,25 +1,24 @@ &1', $output, $return_var); return ['output' => $output, 'return_var' => $return_var]; } -// Function to find LiteSpeed installation path +// Function to find LiteSpeed installation path (Virtuozzo specific) function find_lsws_path() { $possible_paths = [ - '/opt/litespeed', // Common Jelastic/Virtuozzo path - '/opt/lsws', // Alternative Jelastic path - '/usr/local/lsws', // Standard LiteSpeed path + '/usr/local/lsws', // Virtuozzo primary path + '/var/www', // Virtuozzo web directory + '/opt/litespeed', // Generic cloud path + '/opt/lsws', // Alternative cloud path '/usr/local/litespeed', // Alternative standard path - '/usr/lsws', // RPM-based installation - '/var/lsws', // Alternative location - '/home/litespeed' // User-based installation + '/usr/lsws' // RPM-based installation ]; foreach ($possible_paths as $path) { @@ -28,30 +27,18 @@ function find_lsws_path() { } } - // Try to find via which command + // Try to find via which command for Virtuozzo $result = run_command('which lshttpd'); if ($result['return_var'] === 0 && !empty($result['output'][0])) { $binary_path = trim($result['output'][0]); - // Remove /bin/lshttpd to get base path + // For Virtuozzo: /var/www/bin/lshttpd -> /usr/local/lsws + if (strpos($binary_path, '/var/www/bin') !== false) { + return '/usr/local/lsws'; + } return dirname(dirname($binary_path)); } - // Try to find binary in common locations - $binary_locations = [ - '/opt/litespeed/bin/lshttpd', - '/opt/lsws/bin/lshttpd', - '/usr/bin/lshttpd', - '/usr/sbin/lshttpd', - '/usr/local/bin/lshttpd' - ]; - - foreach ($binary_locations as $binary) { - if (file_exists($binary)) { - return dirname(dirname($binary)); - } - } - - return '/opt/litespeed'; // Jelastic/Virtuozzo default fallback + return '/usr/local/lsws'; // Virtuozzo default } // Function to check if LiteSpeed is running @@ -79,17 +66,14 @@ function check_lsws_status() { ]; } -// Function to get LiteSpeed version +// Function to get LiteSpeed version (Virtuozzo specific) function get_lsws_version() { - $lsws_path = find_lsws_path(); + // Virtuozzo specific binary locations $binary_paths = [ - "$lsws_path/bin/lshttpd", - "$lsws_path/bin/litespeed", - "/opt/litespeed/bin/lshttpd", - "/opt/lsws/bin/lshttpd", - "/usr/bin/lshttpd", - "/usr/sbin/lshttpd", - "/usr/local/bin/lshttpd" + '/var/www/bin/lshttpd', // Virtuozzo primary location + '/usr/local/lsws/bin/lshttpd', // Standard location + '/usr/bin/lshttpd', + '/usr/sbin/lshttpd' ]; foreach ($binary_paths as $binary) { @@ -110,26 +94,6 @@ function get_lsws_version() { } } - // Try alternative version detection commands - $version_commands = [ - 'lshttpd -v', - 'litespeed -v', - '/opt/litespeed/bin/lshttpd -v', - '/opt/lsws/bin/lshttpd -v' - ]; - - foreach ($version_commands as $cmd) { - $result = run_command($cmd); - if ($result['return_var'] === 0 && !empty($result['output'])) { - foreach ($result['output'] as $line) { - if (preg_match('/LiteSpeed.*?(\d+\.\d+(?:\.\d+)?)/i', $line, $matches)) { - return "LiteSpeed Web Server " . $matches[1]; - } - } - return trim($result['output'][0]); - } - } - return 'unknown'; } @@ -142,17 +106,14 @@ function get_lsws_processes() { ]; } -// Function to check LiteSpeed configuration +// Function to check LiteSpeed configuration (Virtuozzo specific) function check_lsws_config() { $lsws_path = find_lsws_path(); $config_paths = [ - "$lsws_path/conf/httpd_config.conf", + "$lsws_path/conf/httpd_config.conf", // Primary Virtuozzo config "$lsws_path/conf/httpd.conf", - "$lsws_path/conf/lshttpd.conf", - "/opt/litespeed/conf/httpd_config.conf", - "/opt/lsws/conf/httpd_config.conf", "/etc/litespeed/httpd_config.conf", - "/etc/lsws/httpd_config.conf" + "/var/www/conf/httpd_config.conf" // Alternative Virtuozzo path ]; $found_configs = []; @@ -175,17 +136,14 @@ function check_lsws_config() { ]; } -// Function to check LiteSpeed logs +// Function to check LiteSpeed logs (Virtuozzo specific) function check_lsws_logs() { $lsws_path = find_lsws_path(); $log_dirs = [ - "$lsws_path/logs", - "/opt/litespeed/logs", - "/opt/lsws/logs", + "$lsws_path/logs", // Primary Virtuozzo logs "/var/log/litespeed", "/var/log/lsws", - "/usr/local/lsws/logs", - "/var/log/httpd", // Sometimes used in Jelastic + "/var/www/logs", // Alternative Virtuozzo path "/home/litespeed/logs" ]; @@ -259,32 +217,41 @@ function get_system_info() { 'uptime_formatted' => $uptime_formatted, 'uptime_seconds' => $uptime_seconds, 'load_average' => sys_getloadavg(), - 'installation_path' => find_lsws_path() + 'installation_path' => find_lsws_path(), + 'platform' => 'Virtuozzo LLSMP' ]; } // Main execution -$lsws_status = check_lsws_status(); -$lsws_version = get_lsws_version(); -$lsws_processes = get_lsws_processes(); -$lsws_config = check_lsws_config(); -$lsws_logs = check_lsws_logs(); -$lsws_ports = check_lsws_ports(); -$system_info = get_system_info(); +try { + $lsws_status = check_lsws_status(); + $lsws_version = get_lsws_version(); + $lsws_processes = get_lsws_processes(); + $lsws_config = check_lsws_config(); + $lsws_logs = check_lsws_logs(); + $lsws_ports = check_lsws_ports(); + $system_info = get_system_info(); -// Output comprehensive LiteSpeed status -echo json_encode([ - 'status' => 'success', - 'server' => [ - 'name' => 'LiteSpeed Web Server', - 'version' => $lsws_version, - 'running' => $lsws_status['running'], - 'service_status' => $lsws_status['status'], - 'service_name' => $lsws_status['service_name'], - 'process_count' => $lsws_processes['count'], - 'listening_ports' => $lsws_ports - ], - 'configuration' => $lsws_config, - 'logs' => $lsws_logs, - 'system' => $system_info -], JSON_PRETTY_PRINT); \ No newline at end of file + // Output comprehensive LiteSpeed status + echo json_encode([ + 'status' => 'success', + 'server' => [ + 'name' => 'LiteSpeed Web Server', + 'version' => $lsws_version, + 'running' => $lsws_status['running'], + 'service_status' => $lsws_status['status'], + 'service_name' => $lsws_status['service_name'], + 'process_count' => $lsws_processes['count'], + 'listening_ports' => $lsws_ports + ], + 'configuration' => $lsws_config, + 'logs' => $lsws_logs, + 'system' => $system_info + ], JSON_PRETTY_PRINT); + +} catch (Exception $e) { + echo json_encode([ + 'status' => 'error', + 'message' => 'Script execution failed: ' . $e->getMessage() + ], JSON_PRETTY_PRINT); +} \ No newline at end of file