OpenLiteSpeed and WordPress work well together because the server has a built-in page cache that the free LiteSpeed Cache plugin controls. Cached pages are served without starting PHP, which keeps a small VPS responsive under traffic. This guide installs WordPress on an existing OpenLiteSpeed server, connects the cache and checks that it works.
Before you start
- OpenLiteSpeed installed with LSPHP. See Install OpenLiteSpeed web server on Ubuntu.
- A virtual host for your domain with rewrites enabled. See Add virtual hosts and domains in OpenLiteSpeed. This guide assumes the document root is
/var/www/example.com/html. - Your domain pointed at the server IP.
- SSH access with
sudo. Examples use Ubuntu withlsphp83; adjust the version to the one you installed.
Step 1: Install the PHP extensions WordPress needs
WordPress needs database, image, XML and multibyte support. Install the LSPHP packages:
sudo apt install lsphp83 lsphp83-common lsphp83-mysql lsphp83-curl lsphp83-intl lsphp83-imagickCheck what is loaded:
/usr/local/lsws/lsphp83/bin/php -mYou should see mysqli, curl, intl, imagick, mbstring, xml and zip among others. If one is missing, look for its package with apt-cache search lsphp83.
Step 2: Create the database
Install MariaDB if it is not already on the server, and run the security script:
sudo apt install mariadb-server
sudo mysql_secure_installationCreate a database and user for the site. Open the MariaDB shell with sudo mariadb and run:
CREATE DATABASE wp_example CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_example'@'localhost' IDENTIFIED BY 'use-a-long-random-password';
GRANT ALL PRIVILEGES ON wp_example.* TO 'wp_example'@'localhost';
FLUSH PRIVILEGES;
EXIT;Use your own strong password and keep it for the next step.
Step 3: Download WordPress
Download the latest release into the document root:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz
sudo rsync -a /tmp/wordpress/ /var/www/example.com/html/
sudo rm -f /var/www/example.com/html/index.htmlSet ownership so the LSPHP process (user nobody, group nogroup on Ubuntu by default) can write to wp-content:
sudo chown -R nobody:nogroup /var/www/example.com/html
sudo find /var/www/example.com/html -type d -exec chmod 755 {} \;
sudo find /var/www/example.com/html -type f -exec chmod 644 {} \;Note: Giving the web user ownership of the whole site lets WordPress update itself. For tighter security, own the files with your deploy user and give the web user write access only to wp-content/uploads. Updates then run through WP-CLI.
Step 4: Check the virtual host settings
In WebAdmin, open your virtual host and confirm:
- General → Index Files includes
index.php. - Rewrite → Enable Rewrite and Auto Load from.htaccess are both Yes. WordPress writes its permalink rules to
.htaccess, and OpenLiteSpeed reads them from there. - Script Handler for
phppoints at an LSPHP version that has the extensions above.
Do a Graceful Restart after any change.
Step 5: Run the WordPress installer
Open http://example.com in a browser. Choose a language, then enter:
- Database name:
wp_example - Username:
wp_example - Password: the one you set
- Database host:
localhost
Finish by setting the site title and an admin account with a strong password. Do not use admin as the username.
Then go to Settings → Permalinks and choose Post name. Save. WordPress writes the rewrite rules to .htaccess. Restart OpenLiteSpeed so it loads them:
sudo /usr/local/lsws/bin/lswsctrl restartStep 6: Turn on LiteSpeed Cache
- In WordPress, go to Plugins → Add New, search for LiteSpeed Cache, install and activate it.
- Open LiteSpeed Cache → Cache and make sure Enable Cache is ON.
- Leave the other settings at their defaults at first. Add CSS and JS optimisation later, one option at a time, and test the site after each one.
The cache only applies to visitors who are not logged in. Logged-in users always see fresh pages.
Check it works
Test the cache from the command line. Request the home page twice:
curl -sI http://example.com/ | grep -i x-litespeed-cache
curl -sI http://example.com/ | grep -i x-litespeed-cacheThe first request may show x-litespeed-cache: miss. The second should show:
x-litespeed-cache: hitIf the header does not appear at all, the cache is off for that request. Also confirm that a post URL such as /hello-world/ loads, which proves permalinks work.
Troubleshooting
- Permalinks return 404: rewrites are off, or OpenLiteSpeed has not reloaded
.htaccess. Enable both rewrite options and restart. - "Error establishing a database connection": the details in
wp-config.phpdo not match the user you created. Test them withmariadb -u wp_example -p wp_example. - No
x-litespeed-cacheheader: you are logged in, a cookie bypasses the cache, or a CDN strips the header. Test from a private window or with curl. - Uploads fail with a permission error: the PHP user cannot write to
wp-content/uploads. Fix ownership on that folder.
Next steps
- Add HTTPS: Add Let's Encrypt SSL to OpenLiteSpeed.
- Lock down the site: WordPress security hardening on a VPS.
- Pick the right plan size: What VPS size do you need for WordPress.
- Run WordPress on your own Linux VPS.
