Test Fix OPCache Litespeed
parent
a6bb2a7e89
commit
83861a3b06
83
mbadmin.jps
83
mbadmin.jps
|
@ -15,6 +15,18 @@ onInstall:
|
|||
- mkdir -p /home/litespeed/mbmanager
|
||||
- mkdir -p /home/litespeed/mbmanager/relay
|
||||
- mkdir -p /home/litespeed/mbmanager/ssl-manager
|
||||
- mkdir -p /home/litespeed/mbmanager/scripts
|
||||
# Download OPCache scripts with verification
|
||||
- cd /home/litespeed/mbmanager/scripts
|
||||
- curl -OL https://deploy-proxy.mightybox.io/tony/mb-admin/raw/branch/main/scripts/check_opcache.php
|
||||
- if [ ! -f check_opcache.php ]; then echo "Failed to download check_opcache.php"; exit 1; fi
|
||||
- curl -OL https://deploy-proxy.mightybox.io/tony/mb-admin/raw/branch/main/scripts/toggle_opcache.php
|
||||
- if [ ! -f toggle_opcache.php ]; then echo "Failed to download toggle_opcache.php"; exit 1; fi
|
||||
- curl -OL https://deploy-proxy.mightybox.io/tony/mb-admin/raw/branch/main/scripts/clear_opcache.php
|
||||
- if [ ! -f clear_opcache.php ]; then echo "Failed to download clear_opcache.php"; exit 1; fi
|
||||
- curl -OL https://deploy-proxy.mightybox.io/tony/mb-admin/raw/branch/main/scripts/update_opcache_settings.sh
|
||||
- if [ ! -f update_opcache_settings.sh ]; then echo "Failed to download update_opcache_settings.sh"; exit 1; fi
|
||||
- chmod +x *.php *.sh
|
||||
# Download WordPress Installer with path verification
|
||||
- cd /home/litespeed/mbmanager
|
||||
- curl -OL https://deploy-proxy.mightybox.io/tony/mb-admin/raw/branch/main/scripts/install-wordpress.sh
|
||||
|
@ -24,8 +36,6 @@ onInstall:
|
|||
- if [ ! -f litespeed_fetch_settings.sh ]; then echo "Failed to download litespeed_fetch_settings.sh"; exit 1; fi
|
||||
- curl -OL https://deploy-proxy.mightybox.io/tony/mb-admin/raw/branch/main/scripts/litespeed_update_settings.sh
|
||||
- if [ ! -f litespeed_update_settings.sh ]; then echo "Failed to download litespeed_update_settings.sh"; exit 1; fi
|
||||
- curl -OL https://deploy-proxy.mightybox.io/tony/mb-admin/raw/branch/main/scripts/update_opcache_settings.sh
|
||||
- if [ ! -f update_opcache_settings.sh ]; then echo "Failed to download update_opcache_settings.sh"; exit 1; fi
|
||||
- chmod +x *.sh
|
||||
# Download relay scripts with verification
|
||||
- cd /home/litespeed/mbmanager/relay
|
||||
|
@ -407,36 +417,34 @@ actions:
|
|||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- OP_INI='/usr/local/lsws/lsphp/etc/php.d/10-opcache.ini'
|
||||
- sed -i 's/opcache.enable=0/opcache.enable=1/' $OP_INI
|
||||
- restartNodes:
|
||||
- nodeGroup: "cp"
|
||||
reboot: true
|
||||
- return: enableSuccess
|
||||
- php /home/litespeed/mbmanager/scripts/toggle_opcache.php enable
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
||||
disable_opcache:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- OP_INI='/usr/local/lsws/lsphp/etc/php.d/10-opcache.ini'
|
||||
- sed -i 's/opcache.enable=1/opcache.enable=0/' $OP_INI
|
||||
- restartNodes:
|
||||
- nodeGroup: "cp"
|
||||
reboot: true
|
||||
- return: disableSuccess
|
||||
- php /home/litespeed/mbmanager/scripts/toggle_opcache.php disable
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
||||
clear_opcache:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- echo "<?php opcache_reset(); ?>" | php
|
||||
- return: clearSuccess
|
||||
- php /home/litespeed/mbmanager/scripts/clear_opcache.php
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
||||
opcache_status:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- echo "<?php echo json_encode(['opcache_enabled' => opcache_get_status(false)['opcache_enabled']]); ?>" | php
|
||||
- php /home/litespeed/mbmanager/scripts/check_opcache.php
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -445,7 +453,7 @@ actions:
|
|||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- echo "<?php \$status = opcache_get_status(false); echo json_encode(['memory_usage' => \$status['memory_usage'], 'opcache_statistics' => \$status['opcache_statistics']]); ?>" | php
|
||||
- php /home/litespeed/mbmanager/scripts/check_opcache.php
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
@ -454,24 +462,25 @@ actions:
|
|||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- echo "<?php \$status = opcache_get_status(true); echo json_encode(['scripts' => \$status['scripts'], 'opcache_statistics' => \$status['opcache_statistics'], 'jit' => \$status['jit']]); ?>" | php
|
||||
- php /home/litespeed/mbmanager/scripts/check_opcache.php
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
||||
opcache_fetch_settings:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- echo "<?php \$ini = parse_ini_file('/usr/local/lsws/lsphp/etc/php.d/10-opcache.ini'); echo json_encode(['memory_consumption' => \$ini['opcache.memory_consumption'], 'interned_strings_buffer' => \$ini['opcache.interned_strings_buffer'], 'max_accelerated_files' => \$ini['opcache.max_accelerated_files'], 'revalidate_freq' => \$ini['opcache.revalidate_freq']]); ?>" | php
|
||||
- php /home/litespeed/mbmanager/scripts/check_opcache.php
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
|
||||
opcache_update_settings:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- bash /home/litespeed/mbmanager/update_opcache_settings.sh "${settings.memory_consumption}" "${settings.interned_strings_buffer}" "${settings.max_accelerated_files}" "${settings.revalidate_freq}"
|
||||
- systemctl restart lsws
|
||||
- bash /home/litespeed/mbmanager/scripts/update_opcache_settings.sh "${settings.memory_consumption}" "${settings.interned_strings_buffer}" "${settings.max_accelerated_files}" "${settings.revalidate_freq}"
|
||||
- restartNodes:
|
||||
- nodeGroup: "cp"
|
||||
reboot: true
|
||||
|
@ -480,32 +489,36 @@ actions:
|
|||
message: "OPCache settings updated successfully."
|
||||
litespeed_status:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- wp --path=/var/www/webroot/ROOT litespeed-option get cache
|
||||
- php /home/litespeed/mbmanager/scripts/check_litespeed.php
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
litespeed_enable:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- wp --path=/var/www/webroot/ROOT litespeed-option set cache 1
|
||||
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php enable
|
||||
- return:
|
||||
type: info
|
||||
message: "LiteSpeed Enabled."
|
||||
message: "${response.out}"
|
||||
litespeed_disable:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- wp --path=/var/www/webroot/ROOT litespeed-option set cache 0
|
||||
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php disable
|
||||
- return:
|
||||
type: info
|
||||
message: "LiteSpeed Disabled."
|
||||
message: "${response.out}"
|
||||
litespeed_purgeall:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- wp --path=/var/www/webroot/ROOT litespeed-purge all
|
||||
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php purge
|
||||
- return:
|
||||
type: info
|
||||
message: "LiteSpeed Purged Cache."
|
||||
message: "${response.out}"
|
||||
litespeed_ver:
|
||||
- cmd[cp]:
|
||||
commands:
|
||||
|
@ -522,29 +535,33 @@ actions:
|
|||
message: "${response.out}"
|
||||
litespeed_set_ttlpub:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- wp --path=/var/www/webroot/ROOT litespeed-option set cache-ttl_pub "${settings.sizettl}"
|
||||
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php set-ttl "${settings.sizettl}"
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
update_cache_exc:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- wp --path=/var/www/webroot/ROOT litespeed-option set cache-exc "${settings.cache_exc_paths}"
|
||||
- php /home/litespeed/mbmanager/scripts/manage_litespeed.php set-exclusions "${settings.cache_exc_paths}"
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
get_litespeed_ttl_values:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- bash /home/litespeed/mbmanager/litespeed_fetch_settings.sh
|
||||
- php /home/litespeed/mbmanager/scripts/check_litespeed.php
|
||||
- return:
|
||||
type: info
|
||||
message: "${response.out}"
|
||||
litespeed_update_settings:
|
||||
- cmd[cp]:
|
||||
user: root
|
||||
commands:
|
||||
- bash /home/litespeed/mbmanager/litespeed_update_settings.sh "${settings.TTL_PUB}" "${settings.TTL_PRIV}" "${settings.TTL_FRONTPAGE}" "${settings.TTL_FEED}"
|
||||
- bash /home/litespeed/mbmanager/scripts/litespeed_update_settings.sh "${settings.TTL_PUB}" "${settings.TTL_PRIV}" "${settings.TTL_FRONTPAGE}" "${settings.TTL_FEED}"
|
||||
- restartNodes:
|
||||
- nodeGroup: "cp"
|
||||
reboot: true
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<?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'
|
||||
]
|
||||
]);
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
if (!extension_loaded('Zend OPcache')) {
|
||||
echo json_encode(['status' => 'not_installed']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!ini_get('opcache.enable')) {
|
||||
echo json_encode(['status' => 'disabled']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$status = opcache_get_status(false);
|
||||
if ($status === false) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Cannot retrieve OPCache status']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo json_encode([
|
||||
'status' => 'enabled',
|
||||
'enabled' => $status['opcache_enabled'],
|
||||
'memory_usage' => [
|
||||
'used' => round($status['memory_usage']['used_memory'] / 1024 / 1024, 2),
|
||||
'free' => round($status['memory_usage']['free_memory'] / 1024 / 1024, 2),
|
||||
'wasted' => round($status['memory_usage']['wasted_memory'] / 1024 / 1024, 2)
|
||||
],
|
||||
'statistics' => [
|
||||
'hits' => $status['opcache_statistics']['hits'],
|
||||
'misses' => $status['opcache_statistics']['misses'],
|
||||
'hit_rate' => round($status['opcache_statistics']['opcache_hit_rate'], 2)
|
||||
]
|
||||
]);
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
if (!extension_loaded('Zend OPcache')) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'OPCache is not installed']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!ini_get('opcache.enable')) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'OPCache is disabled']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$result = opcache_reset();
|
||||
if ($result === false) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Failed to reset OPCache']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'message' => 'OPCache cleared successfully']);
|
|
@ -709,59 +709,6 @@ fi
|
|||
# --- Let's Encrypt SSL Certificate Setup ---
|
||||
info "Setting up Let's Encrypt SSL certificate..."
|
||||
|
||||
# First, validate that the domain is publicly accessible
|
||||
info "Validating domain accessibility for SSL certificate..."
|
||||
|
||||
# Check if domain resolves to this server
|
||||
DOMAIN_VALIDATION_FAILED=false
|
||||
|
||||
# Get server's public IP
|
||||
SERVER_IP=$(curl -s ifconfig.me 2>/dev/null || curl -s ipinfo.io/ip 2>/dev/null || curl -s icanhazip.com 2>/dev/null)
|
||||
if [[ -z "$SERVER_IP" ]]; then
|
||||
warning "Could not determine server's public IP address."
|
||||
DOMAIN_VALIDATION_FAILED=true
|
||||
else
|
||||
info "Server public IP: $SERVER_IP"
|
||||
fi
|
||||
|
||||
# Check if domain resolves
|
||||
if [[ "$DOMAIN_VALIDATION_FAILED" == "false" ]]; then
|
||||
DOMAIN_IP=$(dig +short "$DOMAIN" 2>/dev/null | tail -n1)
|
||||
if [[ -z "$DOMAIN_IP" ]]; then
|
||||
warning "Domain '$DOMAIN' does not resolve to any IP address."
|
||||
warning "Domain needs to be publicly accessible and point to this server for SSL to work."
|
||||
DOMAIN_VALIDATION_FAILED=true
|
||||
elif [[ "$DOMAIN_IP" != "$SERVER_IP" ]]; then
|
||||
warning "Domain '$DOMAIN' resolves to $DOMAIN_IP, but server IP is $SERVER_IP."
|
||||
warning "Domain must point to this server for Let's Encrypt validation to work."
|
||||
DOMAIN_VALIDATION_FAILED=true
|
||||
else
|
||||
success "Domain validation passed: $DOMAIN resolves to $SERVER_IP"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if domain is accessible via HTTP
|
||||
if [[ "$DOMAIN_VALIDATION_FAILED" == "false" ]]; then
|
||||
info "Testing HTTP accessibility for domain validation..."
|
||||
HTTP_TEST=$(curl -s -o /dev/null -w "%{http_code}" "http://$DOMAIN" --connect-timeout 10 --max-time 30 2>/dev/null)
|
||||
if [[ "$HTTP_TEST" != "200" && "$HTTP_TEST" != "301" && "$HTTP_TEST" != "302" ]]; then
|
||||
warning "Domain '$DOMAIN' is not accessible via HTTP (got status: ${HTTP_TEST:-'timeout/error'})."
|
||||
warning "Let's Encrypt needs HTTP access for domain validation."
|
||||
DOMAIN_VALIDATION_FAILED=true
|
||||
else
|
||||
success "Domain is accessible via HTTP (status: $HTTP_TEST)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Proceed with SSL only if domain validation passed
|
||||
if [[ "$DOMAIN_VALIDATION_FAILED" == "true" ]]; then
|
||||
warning "Domain validation failed. Skipping SSL certificate generation."
|
||||
info "To get SSL later:"
|
||||
info "1. Ensure your domain '$DOMAIN' points to this server ($SERVER_IP)"
|
||||
info "2. Make sure port 80 is open and accessible from the internet"
|
||||
info "3. Run: sudo certbot --webroot -w '$WP_ROOT' -d '$DOMAIN' --email '$WP_ADMIN_EMAIL' --agree-tos"
|
||||
info "WordPress will work without SSL, but HTTPS is recommended for production sites."
|
||||
else
|
||||
# Install certbot if not present
|
||||
if ! command_exists certbot; then
|
||||
info "Installing certbot for Let's Encrypt certificate management..."
|
||||
|
@ -844,7 +791,6 @@ else
|
|||
warning "Certbot not available. SSL certificate not generated."
|
||||
info "Please install certbot manually and run: sudo certbot --webroot -w '$WP_ROOT' -d '$DOMAIN'"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- Final Summary ---
|
||||
success "WordPress setup process completed!"
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Check if WP-CLI is available
|
||||
if [ ! -f "/home/litespeed/bin/wp" ]; then
|
||||
echo "WP-CLI not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to run WP-CLI commands
|
||||
run_wp_command() {
|
||||
/home/litespeed/bin/wp --path=/var/www/webroot/ROOT "$@"
|
||||
}
|
||||
|
||||
# Check for correct number of arguments
|
||||
if [ "$#" -ne 4 ]; then
|
||||
echo "Usage: $0 TTL_PUB TTL_PRIV TTL_FRONTPAGE TTL_FEED"
|
||||
|
@ -12,14 +23,14 @@ TTL_PRIV=$2
|
|||
TTL_FRONTPAGE=$3
|
||||
TTL_FEED=$4
|
||||
|
||||
# CD into WordPress directory
|
||||
cd /var/www/webroot/ROOT
|
||||
# Update TTL values
|
||||
run_wp_command litespeed-option set cache-ttl_pub "$TTL_PUB"
|
||||
run_wp_command litespeed-option set cache-ttl_priv "$TTL_PRIV"
|
||||
run_wp_command litespeed-option set cache-ttl_frontpage "$TTL_FRONTPAGE"
|
||||
run_wp_command litespeed-option set cache-ttl_feed "$TTL_FEED"
|
||||
|
||||
# Run wp-cli
|
||||
wp litespeed-option set cache-ttl_pub "$TTL_PUB"
|
||||
wp litespeed-option set cache-ttl_priv "$TTL_PRIV"
|
||||
wp litespeed-option set cache-ttl_frontpage "$TTL_FRONTPAGE"
|
||||
wp litespeed-option set cache-ttl_feed "$TTL_FEED"
|
||||
# Purge cache
|
||||
run_wp_command litespeed-purge all
|
||||
|
||||
echo "Cache settings updated successfully."
|
||||
echo "LiteSpeed cache settings updated successfully"
|
||||
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
$action = $argv[1] ?? 'status';
|
||||
$value = $argv[2] ?? '';
|
||||
|
||||
// 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];
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'enable':
|
||||
run_wp_command('litespeed-option set cache 1');
|
||||
run_wp_command('litespeed-purge all');
|
||||
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed cache enabled and purged']);
|
||||
break;
|
||||
|
||||
case 'disable':
|
||||
run_wp_command('litespeed-option set cache 0');
|
||||
run_wp_command('litespeed-purge all');
|
||||
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed cache disabled and purged']);
|
||||
break;
|
||||
|
||||
case 'purge':
|
||||
run_wp_command('litespeed-purge all');
|
||||
echo json_encode(['status' => 'success', 'message' => 'LiteSpeed cache purged']);
|
||||
break;
|
||||
|
||||
case 'set-ttl':
|
||||
if (empty($value)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'TTL value required']);
|
||||
exit(1);
|
||||
}
|
||||
run_wp_command("litespeed-option set cache-ttl_pub $value");
|
||||
run_wp_command('litespeed-purge all');
|
||||
echo json_encode(['status' => 'success', 'message' => "TTL set to $value and cache purged"]);
|
||||
break;
|
||||
|
||||
case 'set-exclusions':
|
||||
if (empty($value)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Exclusion paths required']);
|
||||
exit(1);
|
||||
}
|
||||
run_wp_command("litespeed-option set cache-exc \"$value\"");
|
||||
run_wp_command('litespeed-purge all');
|
||||
echo json_encode(['status' => 'success', 'message' => 'Cache exclusions updated and cache purged']);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid action']);
|
||||
exit(1);
|
||||
}
|
|
@ -164,7 +164,7 @@ update_httpd_config() {
|
|||
local domain="$1"
|
||||
local ip="$2"
|
||||
local listener_name="HTTPS-$domain"
|
||||
local vhost_name="Jelastic"
|
||||
local vhost_name="Default"
|
||||
|
||||
log "Checking if listener exists for '$listener_name'..."
|
||||
local existing
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
$action = $argv[1] ?? 'status';
|
||||
$ini_file = '/usr/local/lsws/lsphp/etc/php.d/10-opcache.ini';
|
||||
|
||||
if (!file_exists($ini_file)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'OPCache configuration file not found']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$ini_content = file_get_contents($ini_file);
|
||||
if ($ini_content === false) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Cannot read OPCache configuration file']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
case 'enable':
|
||||
$new_content = preg_replace('/opcache\.enable\s*=\s*0/', 'opcache.enable = 1', $ini_content);
|
||||
break;
|
||||
case 'disable':
|
||||
$new_content = preg_replace('/opcache\.enable\s*=\s*1/', 'opcache.enable = 0', $ini_content);
|
||||
break;
|
||||
default:
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid action']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (file_put_contents($ini_file, $new_content) === false) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Cannot write to OPCache configuration file']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Restart LiteSpeed to apply changes
|
||||
exec('service lsws restart', $output, $return_var);
|
||||
if ($return_var !== 0) {
|
||||
echo json_encode(['status' => 'warning', 'message' => 'OPCache ' . $action . 'd but LiteSpeed restart failed']);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'message' => 'OPCache ' . $action . 'd successfully']);
|
Loading…
Reference in New Issue