How to Create Virtual Hosts in OpenLiteSpeed Web Server
In our last article, we discussed the installation of OpenLiteSpeed on CentOS 7, Ubuntu 16.04, and Debian 9. Also, covered some of the important configurations such as Enabling support for PHP 7.0, Configure OpenLiteSpeed to use standard HTTP port 80, and MySQL DB Support.
Here are the links to the installation of OpenLiteSpeed,
READ: How to Install OpenLiteSpeed, PHP 7.0 & MariaDB on CentOS 7
READ: How to Install OpenLiteSpeed, PHP 7.0 & MariaDB on Ubuntu 16.04 / Debian 9
To begin, log in to OpenLiteSpeed WeAdmin console by going to below URL.
OR
Create Virtual Hosts in OpenLiteSpeed web server:
Go to Virtual Hosts section and click on Add icon.

Add the below configuration:
Variables | Value |
---|---|
Virtual Host Name | web.itzgeek.local |
Virtual Host Root | $SERVER_ROOT/web.itzgeek.local/ |
Config File | $SERVER_ROOT/conf/vhosts/$VH_NAME/web.itzgeek.local.conf |
Follow Symbolic Link | Yes |
Enable Scripts/ExtApps | Yes |
Restrained | Yes |
ExtApp Set UID Mode | Server UID |

In the configuration, we have used variables for relative paths.
Variables | Path | Remarks |
---|---|---|
$SERVER_ROOT | /usr/local/lsws/ | A location where OpenLiteSpeed is present |
$VH_ROOT | /usr/local/lsws/$VH_NAME | Specifies the root directory of the virtual host where all the files related to the virtual host (like log files, CGI scripts, etc). Note: This is NOT the document root |
Config DIR | /usr/local/lsws/conf/vhosts/$VH_NAME | The configuration filename and directory for this virtual host |
When you click on the save button; OpenLiteSpeed will through an error saying config file does not exist. So, CLICK ON CREATE to let OpenLiteSpeed creates virtual host configuration file for you.

You would get a message like below on the successful creation of virtual host configuration file.

Final Configuration may look like this:

Once the virtual host is created, go to Virtual Hosts –> Choose Virtual Host (web.itzgeek.local) –> General and modify the configurations like shown below.
Variables | Value |
---|---|
Document Root | $VH_ROOT/html/ |
Domain Name | web.itzgeek.local |
Enable GZIP Compression | Yes |

Variables we have used here are,
Variables | Path | Remarks |
---|---|---|
$VH_ROOT/html/ | /usr/local/lsws/$VH_NAME/html | This the document root. |
Go to Virtual Hosts –> Choose Virtual Host (web.itzgeek.local) –> General –> Index Files. Set the index file name.
Variables | Value |
---|---|
Use Server Index Files | No |
Index Files | index.html |
Auto Index | No |

Go to Virtual Hosts –> Choose Virtual Host (web.itzgeek.local) –> Log —> Virtual Host Log. Set the log file to store OpenLiteSpeed error logs.
Variables | Value |
---|---|
Use Server’s Log | Yes |
File Name | $VH_ROOT/logs/error.log |
Log Level | ERROR |
Rolling Size (bytes) | 10M |

Go to Virtual Hosts –> Choose Virtual Host (web.itzgeek.local) –> Log –> Access Log. Set the log file to store OpenLiteSpeed access logs.
Variables | Value |
---|---|
Log Control | Own Log File |
File Name | $VH_ROOT/logs/access.log |
Piped Logger | Not Set |
Log Format | Not Set |
Log Headers | Not Set |
Rolling Size (bytes) | 10M |
Keep Days | 30 |
Bytes log | Not Set |
Compress Archive | Yes |

Go to Virtual Hosts –> Choose Virtual Host (web.itzgeek.local) –> Log –> Security. Allow everyone to access web pages.
Variables | Value |
---|---|
Allowed List | * |

Map Virtual Host in OpenLiteSpeed:
Once you have configured a virtual host, you need to map the virtual host with specific domain so that you can access it via fully qualified domain. To do that, go to Listeners and click on Zoom icon view the Default listener.

Now, add virtual host mapping.

Use the below details.
Variables | Value |
---|---|
Virtual Host | web.tzgeek.local |
Domains | web.itzgeek.local |

Create Document root:
Now, create the document root and logs directory for the virtual host.
mkdir /usr/local/lsws/web.itzgeek.local/ mkdir /usr/local/lsws/web.itzgeek.local/{html,logs}
Create index.html with some content.
echo "This page served by OpenLiteSpeed Web Server running on Linux Operating System" > /usr/local/lsws/web.itzgeek.local/html/index.html
Restart the OpenLiteSpeed service.

The dashboard may look like below:

Verify Virtual Hosts in OpenLiteSpeed:
Visit the following URL using your favorite web browser.
You can see the output like below:

That’s All. You have successfully configured Virtual Hosts on OpenLiteSpeed web server.