fix llsmp directories
parent
657d374681
commit
c4b88520d1
|
@ -1,25 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
// LiteSpeed Web Server Status Check for LLSMP
|
// LiteSpeed Web Server Status Check for Virtuozzo LLSMP
|
||||||
// No WordPress or WP-CLI required
|
// No WordPress or WP-CLI required
|
||||||
|
|
||||||
// Function to execute system commands safely
|
// Function to execute system commands safely
|
||||||
function run_command($command) {
|
function run_command($command) {
|
||||||
$output = [];git ad
|
$output = [];
|
||||||
$return_var = 0;
|
$return_var = 0;
|
||||||
exec($command . ' 2>&1', $output, $return_var);
|
exec($command . ' 2>&1', $output, $return_var);
|
||||||
return ['output' => $output, 'return_var' => $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() {
|
function find_lsws_path() {
|
||||||
$possible_paths = [
|
$possible_paths = [
|
||||||
'/opt/litespeed', // Common Jelastic/Virtuozzo path
|
'/usr/local/lsws', // Virtuozzo primary path
|
||||||
'/opt/lsws', // Alternative Jelastic path
|
'/var/www', // Virtuozzo web directory
|
||||||
'/usr/local/lsws', // Standard LiteSpeed path
|
'/opt/litespeed', // Generic cloud path
|
||||||
|
'/opt/lsws', // Alternative cloud path
|
||||||
'/usr/local/litespeed', // Alternative standard path
|
'/usr/local/litespeed', // Alternative standard path
|
||||||
'/usr/lsws', // RPM-based installation
|
'/usr/lsws' // RPM-based installation
|
||||||
'/var/lsws', // Alternative location
|
|
||||||
'/home/litespeed' // User-based installation
|
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($possible_paths as $path) {
|
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');
|
$result = run_command('which lshttpd');
|
||||||
if ($result['return_var'] === 0 && !empty($result['output'][0])) {
|
if ($result['return_var'] === 0 && !empty($result['output'][0])) {
|
||||||
$binary_path = trim($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));
|
return dirname(dirname($binary_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to find binary in common locations
|
return '/usr/local/lsws'; // Virtuozzo default
|
||||||
$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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to check if LiteSpeed is running
|
// 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() {
|
function get_lsws_version() {
|
||||||
$lsws_path = find_lsws_path();
|
// Virtuozzo specific binary locations
|
||||||
$binary_paths = [
|
$binary_paths = [
|
||||||
"$lsws_path/bin/lshttpd",
|
'/var/www/bin/lshttpd', // Virtuozzo primary location
|
||||||
"$lsws_path/bin/litespeed",
|
'/usr/local/lsws/bin/lshttpd', // Standard location
|
||||||
"/opt/litespeed/bin/lshttpd",
|
'/usr/bin/lshttpd',
|
||||||
"/opt/lsws/bin/lshttpd",
|
'/usr/sbin/lshttpd'
|
||||||
"/usr/bin/lshttpd",
|
|
||||||
"/usr/sbin/lshttpd",
|
|
||||||
"/usr/local/bin/lshttpd"
|
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($binary_paths as $binary) {
|
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';
|
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() {
|
function check_lsws_config() {
|
||||||
$lsws_path = find_lsws_path();
|
$lsws_path = find_lsws_path();
|
||||||
$config_paths = [
|
$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/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/litespeed/httpd_config.conf",
|
||||||
"/etc/lsws/httpd_config.conf"
|
"/var/www/conf/httpd_config.conf" // Alternative Virtuozzo path
|
||||||
];
|
];
|
||||||
|
|
||||||
$found_configs = [];
|
$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() {
|
function check_lsws_logs() {
|
||||||
$lsws_path = find_lsws_path();
|
$lsws_path = find_lsws_path();
|
||||||
$log_dirs = [
|
$log_dirs = [
|
||||||
"$lsws_path/logs",
|
"$lsws_path/logs", // Primary Virtuozzo logs
|
||||||
"/opt/litespeed/logs",
|
|
||||||
"/opt/lsws/logs",
|
|
||||||
"/var/log/litespeed",
|
"/var/log/litespeed",
|
||||||
"/var/log/lsws",
|
"/var/log/lsws",
|
||||||
"/usr/local/lsws/logs",
|
"/var/www/logs", // Alternative Virtuozzo path
|
||||||
"/var/log/httpd", // Sometimes used in Jelastic
|
|
||||||
"/home/litespeed/logs"
|
"/home/litespeed/logs"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -259,11 +217,13 @@ function get_system_info() {
|
||||||
'uptime_formatted' => $uptime_formatted,
|
'uptime_formatted' => $uptime_formatted,
|
||||||
'uptime_seconds' => $uptime_seconds,
|
'uptime_seconds' => $uptime_seconds,
|
||||||
'load_average' => sys_getloadavg(),
|
'load_average' => sys_getloadavg(),
|
||||||
'installation_path' => find_lsws_path()
|
'installation_path' => find_lsws_path(),
|
||||||
|
'platform' => 'Virtuozzo LLSMP'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main execution
|
// Main execution
|
||||||
|
try {
|
||||||
$lsws_status = check_lsws_status();
|
$lsws_status = check_lsws_status();
|
||||||
$lsws_version = get_lsws_version();
|
$lsws_version = get_lsws_version();
|
||||||
$lsws_processes = get_lsws_processes();
|
$lsws_processes = get_lsws_processes();
|
||||||
|
@ -288,3 +248,10 @@ echo json_encode([
|
||||||
'logs' => $lsws_logs,
|
'logs' => $lsws_logs,
|
||||||
'system' => $system_info
|
'system' => $system_info
|
||||||
], JSON_PRETTY_PRINT);
|
], JSON_PRETTY_PRINT);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo json_encode([
|
||||||
|
'status' => 'error',
|
||||||
|
'message' => 'Script execution failed: ' . $e->getMessage()
|
||||||
|
], JSON_PRETTY_PRINT);
|
||||||
|
}
|
Loading…
Reference in New Issue