How to add a website in OpenLiteSpeed ​​web server

Tutorials 0 lượt xem
This article is part 2 of 4 in the OpenLiteSpeed ​​User Guide series

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. 

how to add website in OpenLiteSpeed ​​1

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
how to add website in OpenLiteSpeed ​​2

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

how to add website in OpenLiteSpeed ​​3

You will get a success message like below: 

how to add website in OpenLiteSpeed ​​4

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
how to add website in OpenLiteSpeed ​​5

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
how to add website in OpenLiteSpeed ​​6

​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
how to add website in OpenLiteSpeed ​​7

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
how to add website in OpenLiteSpeed ​​8

Switch to the Security tab . Enter the following information and then click the Save button: 

Variables Value
Allowed List *
how to add website in OpenLiteSpeed ​​9

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. ​

how to add website in OpenLiteSpeed ​​10

Now add virtual host mapping. 

how to add website in OpenLiteSpeed ​​11

Enter the following information and then click the Save button.

Variables Value
Virtual Host elegantjava.info
Domains elegantjava.info
how to add website in OpenLiteSpeed ​​12

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

how to add website in OpenLiteSpeed ​​13

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:

Next create an index.html file for testing:

Here you can access the website on the browser. If you see this message, everything is OK.

how to add website in OpenLiteSpeed ​​14

If you have any trouble, leave a comment below.

View articles in the series

Previous part: How to install OpenLiteSpeed, PHP 7.1 and MariaDB on CentOS Next part: How to install WordPress in OpenLiteSpeed ​​web server

Bài viết liên quan