mb-admin/scripts/check_litespeed.php

54 lines
1.7 KiB
PHP
Raw Normal View History

2025-06-13 17:17:12 +00:00
<?php
$wp_path = '/var/www/webroot/ROOT';
// Check if WP-CLI is available
if (!file_exists('/home/litespeed/bin/wp')) {
echo json_encode(['status' => 'error', 'message' => 'WP-CLI not found']);
exit(1);
}
// Function to run WP-CLI commands
function run_wp_command($command) {
$output = [];
$return_var = 0;
exec("/home/litespeed/bin/wp --path=/var/www/webroot/ROOT $command", $output, $return_var);
return ['output' => $output, 'return_var' => $return_var];
}
// Get cache status
$cache_status = run_wp_command('litespeed-option get cache');
$cache_enabled = ($cache_status['output'][0] ?? '0') === '1';
// Get version
$version = run_wp_command('litespeed-option get _version');
// Get TTL values
$ttl_pub = run_wp_command('litespeed-option get cache-ttl_pub');
$ttl_priv = run_wp_command('litespeed-option get cache-ttl_priv');
$ttl_frontpage = run_wp_command('litespeed-option get cache-ttl_frontpage');
$ttl_feed = run_wp_command('litespeed-option get cache-ttl_feed');
// Get cache exclusion paths
$cache_exc = run_wp_command('litespeed-option get cache-exc');
// Check if LiteSpeed server is running
$lsws_status = [];
exec('systemctl is-active lsws', $lsws_status, $lsws_return);
echo json_encode([
'status' => 'success',
'cache' => [
'enabled' => $cache_enabled,
'version' => $version['output'][0] ?? 'unknown',
'ttl' => [
'public' => $ttl_pub['output'][0] ?? '0',
'private' => $ttl_priv['output'][0] ?? '0',
'frontpage' => $ttl_frontpage['output'][0] ?? '0',
'feed' => $ttl_feed['output'][0] ?? '0'
],
'exclusions' => $cache_exc['output'][0] ?? ''
],
'server' => [
'status' => $lsws_status[0] ?? 'unknown'
]
]);