Easy OpenLiteSpeed Virtual Hosts With ACME

Now you can use ACME (Automatic Certificate Management Environment) in OpenLiteSpeed (OLS) to add new WordPress virtual hosts (vhosts) more easily.
Starting in OpenLiteSpeed version 1.9, certificates can be automatically generated and renewed without the hassle of complex specifications or uploads. If you are buying certificates, you can stop buying them—OpenLiteSpeed will generate them for you now, saving you money and hassle. If you are using Certbot to create or renew your certificates, you can simplify the process by allowing OpenLiteSpeed to do it all for you.
OpenLiteSpeed uses the open-source ACME facility and acme.sh to generate certificates for free. It is fully documented in the OpenLiteSpeed ACME documentation.
Some caveats:
- This feature is only for OpenLiteSpeed Linux servers that run as root.
- Servers must be internet-connected.
- They must be configured to send and receive requests on the default HTTP port (80) and a secure port (typically 443, but any port works).
This blog post is for you if you have a new domain and want to generate a fresh WordPress install for that new domain. The process described here will generate the vhost in OpenLiteSpeed, generate the new certificate, and apply it using our Auto Setup via Script method.
Configuring OpenLiteSpeed
To get certificate generation started, you need to install the ACME facility within OpenLiteSpeed. This only needs to be performed once:
sudo /usr/local/lsws/admin/misc/install_acme.sh
Then you must configure OpenLiteSpeed to use ACME to generate certificates. It is most convenient to do it at the server configuration level, which ensures that newly created vhosts take advantage of the ACME certificates. Because OpenLiteSpeed ACME will continue to honor any filename-specified certificates, this will not affect any systems that were already configured.
To do this:
- In the OpenLiteSpeed WebAdmin Console, navigate to Server Configuration > Tuning.
- In the SSL Global Settings group, press the Edit icon.
- For AutoCert with ACME, select
On. - Press the Save icon to save the configuration.
- Press the Graceful Restart option at the top of the screen to apply it.
After this, any vhosts mapped to a listener will have certificates applied.
Creating and activating a new WordPress installation
This process assumes that you have purchased a domain name that points to your OpenLiteSpeed server. It creates the OpenLiteSpeed vhost and the certificate, and installs WordPress for it.
If your domain is example.com, run the following command, replacing example.com with your domain name:
/bin/bash <( curl -sk https://raw.githubusercontent.com/litespeedtech/ls-cloud-image/master/Setup/vhsetup.sh ) -d example.com -f -w
You should see something like this:
Current platform is centos 9.
ACME Overall set
Vhost created success!
Setting WordPress
Install litespeed-cache.zip
ed exist
Finish WordPress
WP downloaded, please access your domain to complete the setup.
Force HTTPS rules added success!
Setup finished!
You can then access your domain by name using HTTPS (like https://example.com) to complete the simplified WordPress install.
That should be all you need to do.
Converting to a wildcard certificate
To convert the certificate created above to a wildcard certificate, you must follow the steps outlined in Wildcard Certificates. In particular, you must:
- Add additional vhost configuration. This is required for wildcard certificates because the configuration must include an ACME API dns_type and DNS-type-specific definitions.
- Modify your listener mapping to use a wildcard.
Comments