Configure Native LiteSpeed Web Server¶
If you are using LiteSpeed Web Server in Native Mode, configuration will be different than if you are using LiteSpeed as a drop-in replacement for an existing Apache server. In Native Mode, you will start with setting up one or more virtual hosts, and then setting up listeners for the HTTP and HTTPS ports.
Set up Virtual Hosts¶
With name-based virtual hosting, you can host more than one website (also called a "virtual host" or "vhost") on each IP address. LiteSpeed provides a default virtual host named DEFAULT
. If you don't need any more virtual hosts, you can skip ahead to Set up Listeners.
In the following steps we will set up a new virtual host that we'll call Example
.
Set up DNS¶
The domain names used by your virtual hosts will need to be forwarded to your web server's IP address. This is commonly done by adding an A
record to the DNS zone file for the website. This is not part of LiteSpeed Web Server configuration. Please see your DNS provider for further instruction, if needed.
Create a new Virtual Host¶
Create directories¶
To create directories for the new Example
virtual host, start at the command line. Add an Example
directory, plus three subdirectories - conf
, html
, and logs
- in your lsws
directory, like so:
mkdir /usr/local/lsws/Example
mkdir /usr/local/lsws/Example/{conf,html,logs}
Change the owner of the conf
directory to lsadm:lsadm
(the WebAdmin Console user) so that only the WebAdmin Console will have the ability to manipulate Example's configuration:
chown lsadm:lsadm /usr/local/lsws/Example/conf
Add to WebAdmin Console¶
Switch to the WebAdmin Console and navigate to Virtual Hosts > Add. Configure the settings like so:
- Virtual Host Name =
Example
- Virtual Host Root =
$SERVER_ROOT/Example
- Config File =
$SERVER_ROOT/conf/vhosts/Example/vhost.xml
- Enable Scripts/ExtApps =
Yes
- Restrained =
No
You might see the following warning if you are starting from scratch with this virtual host's configuration. Go ahead and click to create:
file /usr/local/lsws/conf/vhosts/Example/vhost.xml does not exist. CLICK TO CREATE
Click the Save button, return to Example's configuration, and change the following settings under the General tab:
- Document Root =
/usr/local/lsws/Example/html
- Index Files =
index.html, index.php
We recommend enabling the Rewrite feature as well. Change the following settings under the Rewrite tab:
- Enable Rewrite =
Yes
Set up Listeners¶
Create a Listener¶
Navigate to Listeners in the WebAdmin Console. There is already a default listener that listens to all IPs on port 8088, but you might want to create another two listeners for both HTTP and HTTPS ports. Here is how:
Click the Add button to create an HTTP listener with following settings:
- Listener Name =
HTTP
- IP Address =
ANY IPv4
- Port =
80
- Secure =
No
Click the Add button to create an HTTPS listener with following settings:
- Listener Name =
HTTPS
- IP Address =
ANY IPv4
- Port =
443
- Secure =
Yes
To configure SSL on the listener you named HTTPS
, navigate to Listeners > HTTPS > SSL, and click the Edit button. Specify the private key and certificate path, then click the Save button. Here are some examples, but be sure to use your own correct file path:
Let's Encrypt:
- Private Key File =
/etc/letsencrypt/live/example.com/privkey.pem
- Certificate File =
/etc/letsencrypt/live/example.com/fullchain.pem
- Chained Certificate =
Yes
Temporary WebAdmin certificate or a private self-signed certificate:
- Private Key File =
/usr/local/lsws/conf/example.key
- Certificate File =
/usr/local/lsws/conf/example.crt
- Chained Certificate =
Not Set
Note
For each IP address, only one process each may bind to ports 80 and 443, so you only need one listener for each port. These two listeners may then be mapped to multiple virtual hosts
Map Virtual Hosts¶
Navigate to Listeners > HTTP > Virtual Host Mappings and click the Add button. Use the following values to map the HTTP listener to the Example virtual host:
- Virtual Host =
Example
- Domains =
example.com, www.example.com
Repeat for the HTTPS listener using the exact same settings.
Set up SSL for Virtual Hosts¶
LiteSpeed Web Server supports Server Name Indication (SNI), allowing users to set SSL certificates at the virtual host level. This is optional, though. If you don't set up SSL at the virtual host level, the HTTPS Listener's SSL settings will be used.
To set up SSL for our Example virtual host in the WebAdmin Console, navigate to Virtual Hosts > Example > SSL > Edit SSL Private Key & Certificate.
Update the new SSL settings with the following example as a guide, using your own file paths:
- Private Key File =
/usr/local/lsws/conf/example.key
- Certificate File =
/usr/local/lsws/conf/example.crt
- Chained Certificate =
Not Set
Tip
Virtual host SSL settings override the Listener SSL settings. Even so, you must not leave the HTTPS listener's SSL configuration blank.