Skip to content

OpenLiteSpeed CLI Tool

This command-line tool—built in Go—can be used for installing and managing OpenLiteSpeed, PHP, and WordPress. It allows you to easily set up and manage domains directly from the terminal.

Tips

  • This tool should be used on a clean server, or you should ensure that no other services are using ports 80, 443, or 7080.
  • Grant database root and sudo access during execution.

Use the one-line installer to install the OpenLiteSpeed CLI binary:

bash <(curl -fsSL https://raw.githubusercontent.com/litespeedtech/ols-cli/master/install_olscli.sh)

Basic syntax:

ols <command> [subcommand] [options]

The following commands are available:

Command Description
install Install or align OpenLiteSpeed runtime and related packages
site Manage sites and virtual hosts
update Update the installed ols binary to the latest release

Global Options:

Option Description
--dry-run Preview command without applying changes
--color Enable colored output

install

ols install [options]

Install OpenLiteSpeed, PHP, and a database.

Parameter Description
--php81 Install PHP 8.1
--php82 Install PHP 8.2
--php83 Install PHP 8.3
--php84 Install PHP 8.4
--php85 Install PHP 8.5
--database Specify database type
--config Path to configuration file
--http-port HTTP port (default: 80)
--https-port HTTPS port (default: 443)
--ssl-cert Path to SSL certificate
--ssl-key Path to SSL key
--no-listeners Skip listener configuration

Example

Install OpenLiteSpeed with default settings:

ols install

Example

Install with PHP 8.5 and MySQL:

ols install --php85 --database mysql

Example

Install with custom configuration:

ols install --config /etc/ols-cli/install.json --php85 --database mysql --http-port 80 --https-port 443

Example

Install without configuring listeners:

ols install --no-listeners

site

ols site <subcommand> [options]

Manage sites and virtual hosts.

The following subcommands are available:

Subcommand Description
create Create a new site or virtual host
update Update an existing site
enable Enable a site at the server level
disable Disable a site at the server level
info Show site metadata and detected status
show Print OpenLiteSpeed virtual host configuration
list List managed sites
delete Remove site configuration and files

site create

ols site create <domain> [options]

Create a new site or virtual host.

Parameter Description
<domain> Domain name for the site
--wp Install WordPress
--le Enable Let's Encrypt SSL
--php81 Use PHP 8.1
--php82 Use PHP 8.2
--php83 Use PHP 8.3
--php84 Use PHP 8.4
--php85 Use PHP 8.5
--enable-owasp Enable OWASP ModSecurity rules
--enable-recaptcha Enable reCAPTCHA protection
--enable-ns Enable namespace isolation
--hsts Enable HTTP Strict Transport Security headers

Example

Create a basic site:

ols site create example.com

Example

Create a WordPress site:

ols site create example.com --wp

Example

Create a WordPress site with Let's Encrypt SSL:

ols site create example.com --wp --le

Example

Create a WordPress site with security features:

ols site create example.com --wp --le --php85 --enable-owasp --enable-recaptcha --hsts --enable-ns

site update

ols site update <domain> [options]

Update an existing site. PHP version is optional when only WordPress, security, or Let's Encrypt flags are used.

Parameter Description
<domain> Domain name of the site to update
--wp Install or update WordPress
--le Enable Let's Encrypt SSL
--php81 Switch to PHP 8.1
--php82 Switch to PHP 8.2
--php83 Switch to PHP 8.3
--php84 Switch to PHP 8.4
--php85 Switch to PHP 8.5
--enable-owasp Enable OWASP ModSecurity rules
--disable-owasp Disable OWASP ModSecurity rules
--enable-recaptcha Enable reCAPTCHA protection
--disable-recaptcha Disable reCAPTCHA protection
--enable-ns Enable namespace isolation
--disable-ns Disable namespace isolation
--hsts Enable HTTP Strict Transport Security headers

Example

Update a site to PHP 8.5:

ols site update example.com --php85

Example

Enable security features:

ols site update example.com --enable-owasp --enable-recaptcha --hsts

Example

Enable namespace isolation:

ols site update example.com --enable-ns

Example

Disable OWASP and namespace isolation:

ols site update example.com --disable-owasp --disable-ns

site enable

ols site enable <domain>

Enable a site at the server level.

Parameter Description
<domain> Domain name of the site to enable

Example

ols site enable example.com

site disable

ols site disable <domain>

Disable a site at the server level.

Parameter Description
<domain> Domain name of the site to disable

Example

ols site disable example.com

site info

ols site info <domain>

Show site metadata and detected status.

Parameter Description
<domain> Domain name of the site

Example

ols site info example.com

site show

ols site show <domain>

Print the OpenLiteSpeed virtual host configuration.

Parameter Description
<domain> Domain name of the site

Example

ols site show example.com

site list

ols site list

List managed sites discovered from the OpenLiteSpeed virtual host directory.

site delete

ols site delete <domain> [options]

Remove site configuration and files.

Parameter Description
<domain> Domain name of the site to delete
--keep-db Keep the database when deleting the site

Example

Delete a site and its database:

ols site delete example.com

Example

Delete a site but keep the database:

ols site delete example.com --keep-db

update

ols update

Update the installed ols binary to the latest GitHub release for the current platform.

Example

ols update

Example

Preview without executing:

ols --dry-run update

Configuration

Custom Configuration File

You can customize the default configuration by creating a configuration file at /etc/ols-cli/install.json.

Create the configuration directory and copy the example configuration:

mkdir -p /etc/ols-cli
cp docs/install.example.json /etc/ols-cli/install.json

Run the installation with the configuration file:

ols install

Configuration Options

The install.json file supports the following options:

  • owasp_crs_version: OWASP Core Rule Set version (for example, "4.21.0") for OWASP CRS setup during ols install
  • vh_recaptcha_type: reCAPTCHA type (default: 1)
  • vh_recaptcha_reg_conn_limit: reCAPTCHA connection limit (default: 500)

Default Security Configuration

By default, ols install prepares server-level security blocks as follows:

  • module mod_security with ls_enabled 0
  • lsrecaptcha with enabled 1 and type 0
  • namespace with 1

Override Configuration with Flags

You can override configuration values using command-line flags:

ols install --config /etc/ols-cli/install.json --php85 --database mysql --http-port 80 --https-port 443

Development

If you'd like to make some code changes, you can build and test a new binary on your own.

Build Locally

go build -o ols ./cmd/ols

Run Tests

go test ./...

For verbose output:

go test -v ./...