Servers

WP Ghost on aaPanel Multi-WebServer Setup | Nginx + OLS

WP Ghost works on aaPanel Multi-WebServer hosting (Nginx + OpenLiteSpeed) with a one-time script fix. In aaPanel’s Multi-WebServer setup, Nginx sits in front as a reverse proxy and OpenLiteSpeed (OLS) handles PHP. The problem: Nginx intercepts static file requests (CSS, JS, images, fonts) and tries to serve them directly from disk. When WP Ghost changes these paths, the files don’t exist at the new locations on disk, so Nginx returns 404 instead of passing the request to OLS where the rewrite rules apply. A provided script fixes this by telling Nginx to forward non-existent static file requests to OLS.

Why aaPanel Multi-WebServer Needs This Fix

In a Multi-WebServer setup, Nginx handles static files directly for performance while OpenLiteSpeed handles PHP and rewrite rules via .htaccess. When WP Ghost changes WordPress paths, the rewritten URLs for static files (like /core/style.css instead of /wp-content/style.css) don’t match real files on disk. Nginx sees these as missing files and returns 404, never reaching OLS where the rewrite rules would map them correctly. The fix script adds a “try file, then forward” rule: if the file exists on disk, Nginx serves it directly (fast); if not, Nginx forwards to OLS (where WP Ghost rewrites apply).

Step 1: Download and Upload the Script

  1. Download and unpack the script:
  1. Log in to aaPanel and go to Website or WP Toolkit.
  2. Find your domain and click Root (or File / Document Root depending on aaPanel version).
  3. Open the website root folder (for example, /www/wwwroot/yourdomain.com/).
  4. Click Upload and upload the openlitespeed.sh script file to the root folder.

Step 2: Make the Script Executable and Run It

  1. In aaPanel, open Terminal (left menu).
  2. Navigate to your site root folder and make the script executable:
cd /www/wwwroot/yourdomain.com
chmod +x openlitespeed.sh
  1. Run the script:
./openlitespeed.sh

To run it for a specific domain only (useful if you host multiple sites):

./openlitespeed.sh yourdomain.com
  1. When the script finishes, you should see:
Testing nginx config...
Reloading nginx...
Done.

Step 3: Verify in WP Ghost

  1. Go to WP Ghost > Change Paths.
  2. Run the Frontend Test.
  3. Run the Login Test.
  4. If everything loads correctly, click “Yes, it’s working”.
  5. If something is broken, click “No, abort” to roll back.

Clear cache after running the script. If you use LiteSpeed Cache, Cloudflare, or any other CDN or caching plugin, clear the cache once to avoid old asset paths being served from cache.

What the Script Does

The script acts as a traffic director between Nginx and OpenLiteSpeed. Here is what it does:

  1. Scans aaPanel Nginx configs at /www/server/panel/vhost/nginx/*.conf to find all domains.
  2. Detects the OpenLiteSpeed upstream for each domain so it knows where to forward requests.
  3. Creates an Nginx extension snippet per domain at /www/server/panel/vhost/nginx/extension/<domain>/static-fallback.conf.
  4. Adds the static file fallback rule: if a static file exists on disk, Nginx serves it directly (fast); if it doesn’t exist, Nginx forwards the request to OpenLiteSpeed where WP Ghost’s rewrite rules apply.
  5. Tests the Nginx config with nginx -t and reloads Nginx so changes apply immediately.
  6. Creates backups of any existing snippet files (adds a .bak.<timestamp> copy).

The script does not replace OpenLiteSpeed or modify WordPress. It only changes how Nginx handles static file requests for domains where rewritten URLs don’t match real files on disk. All other functionality remains unchanged.

Troubleshooting

“Permission denied” when running the script

You’re not in the correct folder or the file isn’t executable. Run:

cd /www/wwwroot/yourdomain.com
chmod +x openlitespeed.sh
./openlitespeed.sh

“nginx binary not found” or “vhost dir not found”

This means either you’re not on an aaPanel server with Nginx installed in the standard location, or Multi-WebServer is not enabled the way the script expects. The script checks for common aaPanel paths and stops safely if they’re missing.

Nginx reload fails

The script tries alternative reload methods (reload, then restart if needed). If it still fails, open aaPanel and go to App Store to confirm Nginx is installed and running.

Assets still broken after running the script

Clear all caches: LiteSpeed Cache plugin, Cloudflare, browser cache. Old asset URLs may still be served from cache. Also verify WP Ghost is configured correctly by checking the Frontend and Login Tests in WP Ghost > Change Paths.

Locked out after configuration

Use the Safe URL parameter to bypass WP Ghost temporarily. If that doesn’t work, see the Emergency Disable guide.

Frequently Asked Questions

Is this a one-time fix?

Yes, in most cases. The script creates an extension snippet that aaPanel’s Nginx includes automatically. If aaPanel updates remove the snippet or change the Nginx config structure, re-run the script. You don’t need to re-run it when changing WP Ghost path settings since the fallback rule works for any rewritten path.

Does this apply if I use OpenLiteSpeed only (without Nginx)?

No. If you use OpenLiteSpeed without Nginx in front, WP Ghost works through .htaccess rewrite rules automatically, just like Apache. This guide is only for the Multi-WebServer setup where Nginx is the reverse proxy in front of OpenLiteSpeed. See Configure .htaccess in OpenLiteSpeed for standalone OLS setups.

Does this affect performance?

No. Real static files that exist on disk are still served directly by Nginx (fast). Only rewritten URLs that don’t match real files are forwarded to OpenLiteSpeed. This is the same “try file, then forward” pattern used by most Nginx reverse proxy setups.

Does WP Ghost modify WordPress core files?

No. WP Ghost uses .htaccess rewrite rules (processed by OpenLiteSpeed) and WordPress hooks for application-level changes. The script modifies only Nginx extension snippets in the aaPanel config directory. No WordPress core files are modified.

Server panel and OpenLiteSpeed configuration:

John Darrel

Change the WordPress Database Prefix for Security

Replace the default wp_ database prefix with a random one to protect against SQL injection…

1 year

Customize WordPress Uploads Directory | WP Ghost

Change the WordPress uploads directory path with WP Ghost (rewrite rules, no files moved) or…

1 year

WP Ghost and WP Rocket Cache Setup Guide

Configure WP Ghost with WP Rocket cache. Enable file optimization, Change Paths in Cache Files.…

1 year

Why is website security important?

https://youtu.be/6ylhojSi-_E In this video, we’ll explore why website security matters and what can happen if…

1 year

Is WordPress Website Easily Hacked?

The security of your WordPress site depends on multiple factors, such as the strength of…

1 year

Set Up WordPress 2FA with Mobile Authenticator Apps

Step-by-step guides to connect WP Ghost 2FA with Google Authenticator, Authy, Microsoft Authenticator, or LastPass.…

1 year