How to add your domain to OpenLiteSpeed Web Server

In this article we will see how we can host our domain to OpenLiteSpeed web server by using Name-based virtual hosting. In this way we can host multiple website/domain against a single IP address or web server.

Before start, make sure you pointed your domain name to your server’s IP address (setup A record)

Creating virtual host for a domain

1. First we will create the necessary directories where our web content’s will be stored. Suppose our domain name is example10.com so we will create ‘example10’ directory first and create other sub directories afterwards within that directory. Note that the public folder of OpenLiteSpeed web server is /usr/local/lsws. So we will create the directories within here.

cd /usr/local/lsws
mkdir example10
cd examle10
mkdir {html,logs}

2. Now login to the OpenLiteSpeed web admin panel and goto “Virtual Hosts”

3. Set up the settings like below:

Virtual Host Name: example10
Virtual Host Root: $SERVER_ROOT/example10
Config File: $SERVER_ROOT/conf/vhosts/example10/vhconf.conf

Enable Scripts/ExtApps: Yes
Restrained: Yes

Now click save

4. You will see an error message that vhconf.conf doesn’t exist. Click on “CLICK TO CREATE” to solve that problem. Now save again

5. Now go to the “Virtual Hosts” again and click on the “View” icon of newly created configuration.

6. Click “General” tab and click the “Edit” button
$VH_ROOT/html

7. Specify the “Document Root” directory and save

Assigning the virtual host to the listeners

Now we will map our domain to the server IP. In this process, we can map multiple domains to a single IP address. Means we can host multiple websites in our server. To do that,

1. Go to “Listeners” and click “View” icon

2. Under “Virtual Host Mappings”, click the edit button

3. Select the previously created virtual host from the dropdown and write down the domain name that you want to add to the server. Click “Save”

4. Finally, click the restart button to take effect the changes

You have successfully added a domain to your server. However, don’t forget to add SSL certificate which brings extra security.

Leave a Reply

Your email address will not be published. Required fields are marked *