How to install WordPress on OpenLiteSpeed with LSCache

Install WordPress on OpenLiteSpeed with the right LSPHP extensions, a MariaDB database and a dedicated virtual host, then turn on the LiteSpeed Cache plugin and confirm cache hits in the response headers.

  • Intermediate
  • Linux VPS
  • 4 min read

By RunRacks Team · Published

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

Step 1: Install the PHP extensions WordPress needs

WordPress needs database, image, XML and multibyte support. Install the LSPHP packages:

Terminal
sudo apt install lsphp83 lsphp83-common lsphp83-mysql lsphp83-curl lsphp83-intl lsphp83-imagick

Check what is loaded:

Terminal
/usr/local/lsws/lsphp83/bin/php -m

You 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:

Terminal
sudo apt install mariadb-server
sudo mysql_secure_installation

Create a database and user for the site. Open the MariaDB shell with sudo mariadb and run:

SQL
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:

Terminal
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.html

Set ownership so the LSPHP process (user nobody, group nogroup on Ubuntu by default) can write to wp-content:

Terminal
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 {} \;

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 php points 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:

Terminal
sudo /usr/local/lsws/bin/lswsctrl restart

Step 6: Turn on LiteSpeed Cache

  1. In WordPress, go to Plugins → Add New, search for LiteSpeed Cache, install and activate it.
  2. Open LiteSpeed Cache → Cache and make sure Enable Cache is ON.
  3. 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:

Terminal
curl -sI http://example.com/ | grep -i x-litespeed-cache
curl -sI http://example.com/ | grep -i x-litespeed-cache

The first request may show x-litespeed-cache: miss. The second should show:

Text
x-litespeed-cache: hit

If 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.php do not match the user you created. Test them with mariadb -u wp_example -p wp_example.
  • No `x-litespeed-cache` header: 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

Was this guide helpful?

Still stuck?

Ask RunRacks AI for a quick answer, or open a ticket and our team will take a look at your server.

Websites & apps

Install PHP 8.x on AlmaLinux and Rocky Linux with Remi

Enable EPEL and the Remi repository on AlmaLinux or Rocky Linux 8 and 9, choose a PHP module stream, install PHP-FPM with common extensions, and run extra PHP versions side by side.

  • Intermediate
  • Linux VPS
  • 4 min read

Websites & apps

Use Apache as a reverse proxy with mod_proxy

Put Apache in front of a Node.js, Python or Docker app with mod_proxy. Set ProxyPass and ProxyPassReverse, keep the original host, proxy WebSockets and serve the app over HTTPS.

  • Intermediate
  • Linux VPS
  • 4 min read

Websites & apps

Enable gzip compression in Apache with mod_deflate

Compress HTML, CSS, JavaScript and JSON in Apache with mod_deflate, add Brotli with mod_brotli for modern browsers and check the Content-Encoding header to prove it works.

  • Beginner
  • Linux VPS
  • 4 min read