Websites & apps

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.

IntermediateLinux server4 min read

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:

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

Check what is loaded:

Bash
/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:

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

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

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

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

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

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 MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.