fix llsmp directories

main
Anthony 2025-06-18 00:08:40 +08:00
parent 657d374681
commit c4b88520d1
1 changed files with 59 additions and 92 deletions

View File

@ -1,25 +1,24 @@
<?php
// LiteSpeed Web Server Status Check for LLSMP
// LiteSpeed Web Server Status Check for Virtuozzo LLSMP
// No WordPress or WP-CLI required
// Function to execute system commands safely
function run_command($command) {
$output = [];git ad
$output = [];
$return_var = 0;
exec($command . ' 2>&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,11 +217,13 @@ 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
try {
$lsws_status = check_lsws_status();
$lsws_version = get_lsws_version();
$lsws_processes = get_lsws_processes();
@ -288,3 +248,10 @@ echo json_encode([
'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);
}