WordPress
Prerequisites
Section titled “Prerequisites”- OpenLiteSpeed installed and running
- PHP 8.1+ with required extensions (see Install PHP)
- MySQL or MariaDB server
- A configured virtual host (see Virtual Hosts)
Database Setup
Section titled “Database Setup”mysql -u root -pCREATE DATABASE wordpress;CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strong_password_here';GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';FLUSH PRIVILEGES;EXIT;Install WordPress
Section titled “Install WordPress”Using WP-CLI (Recommended)
Section titled “Using WP-CLI (Recommended)”# Install WP-CLIcurl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.pharchmod +x wp-cli.pharmv wp-cli.phar /usr/local/bin/wp
# Download WordPresscd /var/www/example.comwp core download --allow-root
# Configurewp config create --allow-root \ --dbname=wordpress \ --dbuser=wpuser \ --dbpass=strong_password_here \ --dbhost=localhost
# Installwp core install --allow-root \ --url=https://example.com \ --title="My Site" \ --admin_user=admin \ --admin_password=admin_password_here \
# Set ownershipchown -R nobody:nobody /var/www/example.comManual Download
Section titled “Manual Download”cd /var/www/example.comwget https://wordpress.org/latest.tar.gztar xzf latest.tar.gz --strip-components=1rm latest.tar.gzchown -R nobody:nobody .Virtual Host Configuration
Section titled “Virtual Host Configuration”virtualhost example { vhRoot /var/www/example.com configFile conf/vhosts/example/vhconf.conf allowSymbolLink 1 enableScript 1 restrained 1
docRoot $VH_ROOT/
index { indexFiles index.php, index.html }
scripthandler { add lsapi:lsphp php }
# Enable .htaccess processing rewrite { enable 1 autoLoadHtaccess 1 }}WordPress Permalink Rewrite Rules
Section titled “WordPress Permalink Rewrite Rules”OLS needs rewrite rules for WordPress pretty permalinks. There are two approaches:
Option A: OLS Native Rewrite (in vhconf.conf)
Section titled “Option A: OLS Native Rewrite (in vhconf.conf)”rewrite { enable 1 autoLoadHtaccess 1
rules <<<END_rules RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] END_rules}Option B: .htaccess (with LiteHTTPD)
Section titled “Option B: .htaccess (with LiteHTTPD)”WordPress automatically creates a .htaccess file. With the LiteHTTPD module loaded, OLS processes it natively:
# WordPress default .htaccess<IfModule mod_rewrite.c>RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]</IfModule>LiteSpeed Cache Plugin
Section titled “LiteSpeed Cache Plugin”The LiteSpeed Cache plugin is the primary advantage of running WordPress on OLS. It provides server-level full-page caching without any additional configuration.
Install the Plugin
Section titled “Install the Plugin”wp plugin install litespeed-cache --activate --allow-rootOr install from the WordPress admin dashboard: Plugins > Add New > search “LiteSpeed Cache”.
Enable OLS Cache Module
Section titled “Enable OLS Cache Module”In httpd_config.conf, ensure the cache module is loaded:
module cache { ls_enabled 1
checkPublicCache 1 checkPrivateCache 1 maxCacheObjSize 10000000 maxStaleAge 200 qsCache 1 reqCookieCache 1 respCookieCache 1 ignoreReqCacheCtrl 1 ignoreRespCacheCtrl 0
storagePath /usr/local/lsws/cachedata}Recommended Plugin Settings
Section titled “Recommended Plugin Settings”After activation, go to LiteSpeed Cache > General:
- Enable LiteSpeed Cache: On
- Guest Mode: On (serves cached pages to first-time visitors)
- Guest Optimization: On
Under LiteSpeed Cache > Cache:
- Cache Logged-in Users: Off (for most sites)
- Cache Commenters: Off
- Cache REST API: On
- Cache Mobile: On (if using a responsive theme, use same cache as desktop)
Cache Purge
Section titled “Cache Purge”# Purge all cache via WP-CLIwp litespeed-purge all --allow-root
# Or via the admin bar in WordPress dashboardWordPress Multisite
Section titled “WordPress Multisite”Subdirectory Multisite
Section titled “Subdirectory Multisite”The default .htaccess rewrite rules work for subdirectory multisite. WordPress generates:
RewriteEngine OnRewriteBase /RewriteRule ^index\.php$ - [L]
# Add a trailing slash to /wp-adminRewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^ - [L]RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]RewriteRule . index.php [L]Subdomain Multisite
Section titled “Subdomain Multisite”For subdomain multisite, configure a wildcard listener in OLS and use the same virtual host with wildcard ServerName:
listener Wildcard { address *:443 secure 1 map example *.example.com, example.com}Security Hardening
Section titled “Security Hardening”Block PHP Execution in Uploads
Section titled “Block PHP Execution in Uploads”With the LiteHTTPD module, add to wp-content/uploads/.htaccess:
<FilesMatch "\.php$"> Require all denied</FilesMatch>Or via OLS context in vhconf.conf:
context /wp-content/uploads/ { allowBrowse 1 location $VH_ROOT/wp-content/uploads/
phpIniOverride { php_admin_flag engine off }}Restrict wp-login.php
Section titled “Restrict wp-login.php”Using .htaccess with the LiteHTTPD module:
<Files wp-login.php> Require ip 192.168.1.0/24</Files>Disable XML-RPC
Section titled “Disable XML-RPC”<Files xmlrpc.php> Require all denied</Files>Performance Tuning
Section titled “Performance Tuning”Recommended php.ini for WordPress
Section titled “Recommended php.ini for WordPress”memory_limit = 256Mupload_max_filesize = 64Mpost_max_size = 64Mmax_execution_time = 300max_input_vars = 5000
; OPcacheopcache.enable = 1opcache.memory_consumption = 256opcache.max_accelerated_files = 10000opcache.revalidate_freq = 60OLS Tuning for WordPress
Section titled “OLS Tuning for WordPress”extprocessor lsphp { type lsapi ... env PHP_LSAPI_CHILDREN=20 env LSAPI_MAX_REQS=5000 env PHP_LSAPI_MAX_IDLE=300 memSoftLimit 2047M memHardLimit 2047M}Troubleshooting
Section titled “Troubleshooting”White screen of death:
- Enable WP_DEBUG in
wp-config.php:define('WP_DEBUG', true); - Check
/usr/local/lsws/logs/error.log
Permalink 404 errors:
- Verify
rewriteis enabled in the virtual host - Check that
autoLoadHtaccessis1or that rewrite rules are in vhconf.conf - Flush rewrite rules: Settings > Permalinks > Save Changes
LiteSpeed Cache not working:
- Verify the OLS cache module is enabled in
httpd_config.conf - Check the
X-LiteSpeed-Cacheresponse header (should behitormiss) - Ensure
storagePathdirectory is writable
Next Steps
Section titled “Next Steps”- LiteSpeed Cache — advanced cache configuration
- Security Headers — add security headers via OLS or .htaccess