In the previous post you learned how to install OpenLiteSpeed, PHP 7.1 and Maria DB on CentOS .
Next, you will learn how to add a website in OpenLiteSpeed. Technically speaking, you will add Virtual Host in OpenLiteSpeed.
In this article, I will illustrate one more domain elegantjava.info . Remember to change the domain accordingly.
To test after you add the domain in OpenLiteSpeed, remember to point the domain to the VPS’s IP .
How to add Virtual Host in OpenLiteSpeed
Visit WebAdmin: http://your_ip_adress:7080
Go to Virtual Hosts -> Add.

Enter details as below:
| Variables | Value |
|---|---|
| Virtual Host Name ($VH_NAME) | elegantjava.info |
| Virtual Host Root ($VH_ROOT) | $SERVER_ROOT/elegantjava.info/ |
| Config File | $SERVER_ROOT/conf/vhosts/$VH_NAME/elegantjava.info.conf |
| Follow Symbolic Link | Yes |
| Enable Scripts/ExtApps | Yes |
| Restrained | Yes |
| ExtApp Set UID Mode | Server UID |
In the configuration section we use some variables for the relative path as follows:
| Variables | Path | Explain |
|---|---|---|
| $SERVER_ROOT | /usr/local/lsws/ | OpenLiteSpeed installation location |
| $VH_ROOT | /usr/local/lsws/$VH_NAME | Website root directory. This is not the directory containing the source code of the website |
| Config DIR | /usr/local/lsws/conf/vhosts/$VH_NAME | File name and configuration directory for the website |

When you click the Save icon in the upper right corner, OpenLiteSpeed will report an error that the configuration file is not found as shown below. You click on the link CLICK TO CREATE FILE :

You will get a success message like below:

As soon as the Virtual Host is successfully created, go to the General tab. Edit the General information as follows. Click the Save button after the import is complete.
| Variables | Value |
|---|---|
| Document Root | $VH_ROOT/html/ (The directory containing the website’s source code. Equivalent to /usr/local/lsws/$VH_NAME/html |
| Domain Name | elegantjava.info |
| Enable GZIP Compression | Yes |

The Index section you edit is as follows. Don’t forget to click the Save button after entering.
| Variables | Value |
|---|---|
| Use Server Index Files | No |
| Index Files | index.html index.php |
| Auto Index | No |

Now switch to the Log tab. First you edit the Virtual Host Log as follows. Click the Save button to save the configuration.
| Variables | Value |
|---|---|
| Use Server’s Log | Yes |
| Filename | $VH_ROOT/logs/error.log |
| Log Level | ERROR |
| Rolling Size (bytes) | 10M |

Switch to the Access Log section. Edit as follows and then click the Save button:
| Variables | Value |
|---|---|
| Log Control | Own Log File |
| Filename | $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 |

Switch to the Security tab . Enter the following information and then click the Save button:
| Variables | Value |
|---|---|
| Allowed List | * |

Map Virtual Host in OpenLiteSpeed
You have configured Virtual Host. Next, you need to map the virtual host to the domain. So you can access the website on the browser.
Go to Listeners. Click the magnifying glass icon to edit the default listener.

Now add virtual host mapping.

Enter the following information and then click the Save button.
| Variables | Value |
|---|---|
| Virtual Host | elegantjava.info |
| Domains | elegantjava.info |

At this point you have completed the configuration part. For OpenLiteSpeed to recognize the new configuration, click the Graceful Restart button.

Create the required directory on the server
You connect to the VPS and run the following 2 commands to create the document root and the log directory:
|
1
2
|
mkdir /usr/local/lsws/elegantjava.info/
mkdir /usr/local/lsws/elegantjava.info/{html,logs}
|
Next create an index.html file for testing:
|
1
|
echo “This page served by OpenLiteSpeed Web Server running on Linux Operating System” > /usr/local/lsws/elegantjava.info/html/index.html
|
Here you can access the website on the browser. If you see this message, everything is OK.

If you have any trouble, leave a comment below.

