25.8 C
Texas
angeloma
Senior Writer and partner

How to create a Virtualhost on OpenLiteSpeed?

Hello, friends. In this post, you will learn how to create a new VirtualHost on OpenLiteSpeed.

The term Virtual Host refers to making more than one Website work on a single machine. Virtual websites can be “IP-based”, which means that each website has a different IP address, or “name-based”, which means that with a single IP address, websites with different domain names are running

Apache was one of the first to support this feature but over time other web servers began to implement it. One of those servers is OpenLiteSpeed.

So, let us start the work.

Creating a new VirtualhHost on OpenLiteSpeed

- Advertisement -

The first thing you have to do is install and configure OpenLiteSpeed properly, in this case, I’m using CentOS but it’s the same process in both Ubuntu or Debian.

So, read our post about it

How to install OpenLiteSpeed on CentOS 8?
How to install OpenLiteSpeed on Ubuntu 20.04?

Then log in and you will see the dashboard.

1.- OpenLiteSpeed dashboard
1.- OpenLiteSpeed dashboard

On the left side, go to the VirtualHosts section to list them.

2.- VirtualHosts summary
2.- VirtualHosts summary

Now, you can create a new one by clicking on the + button on the right.

3.- Creating a new Virtualhost on OpenLiteSpeed
3.- Creating a new Virtualhost on OpenLiteSpeed

There you have to enter the data of the new VirtualHost. In my case, I have chosen the following values that you can modify as you wish.

Virtual Host Name test.osradar.local
Virtual Host Root $SERVER_ROOT/test.osradar.local/
Config File $SERVER_ROOT/conf/vhosts/$VH_NAME/test.osradar.local.conf
Follow Symbolic Link Yes
Enable Scripts/ExtApps Yes
Restrained Yes
ExtApp Set UID Mode Server UID

Then, click on the Diskette button to save the changes.

As I have pointed out that a configuration file that does not exist, the following message will jump.

4.- New Virtualhost data
4.- New Virtualhost data

Click on the CLICK TO CREATE link to create it automatically. You will see the following screen.

5.- File configuration created
5.- File configuration created

Again click on the button to save the changes. And you will see the new Virtualhost created.

6.- Virtualhost created
6.- Virtualhost created

Configuring the new Virtualhost on OpenLiteSpeed

The new Virtualhost is already created, but it is convenient to make some configurations to leave it fully functional.

To do so, from the Virtualhost summary screen, click on the magnifying glass of the new virtualhost to see and modify its values.

In the General tab, you will see the basic information that is empty.

7.- Configuring the new Virtualhost
7.- Configuring the new Virtualhost

To enter data, click on the edit button on the right.

On the next screen, set the values you need. In my case, I have chosen the following:

Document Root $VH_ROOT/html/
Domain Name test.osradar.local
Enable GZIP Compression Yes
8.- Configuring the new Virtualhost
8.- Configuring the new Virtualhost

Then click on the Save button.

Now do the same but in the Index Files section.

9.- Index file section
9.- Index file section

And in the Index File field add the value index.php

9.- Adding a new entry on the Virtualhost configuration
9.- Adding a new entry on the Virtualhost configuration

Then click on the Save button.

Now we will configure the logs of the new VirtualHost that will help us to keep track of it.

So, go to the Log tab and you will see the default information and the Virtual Host Log and Access Log sections

10.- Log configurations
10.- Log configurations

Click the edit button in the Virtual Host Log section and set the values you need. In this case, I have chosen these.

Use Server’s Log Yes
File Name $VH_ROOT/logs/error.log
Log Level ERROR
Rolling Size (bytes) 10M
Keep Days 45
11.- Virtual Hosts Log configuration
11.- Virtual Hosts Log configuration

To save the changes, click on the Save button.

Now it’s time to work with the Access Log section. To do this, create a new one by clicking on the + button

And add the following values

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 45
Bytes log Not Set
Compress Archive Yes
12.-Creating the Log files
12.-Creating the Log files

Then save the changes.

More configurations

The next step is to go to the Security tab and position ourselves in the Access Control section

13.- Access Control section
13.- Access Control section

This value is where we will specify the hosts that can access VirtualHost.

Click on the edit button and in the Allowed List field specify the Hosts. If you want it to be accessible to everyone, type *

14.- Access Control section
14.- Access Control section

Now click on the Save button.

Then, on the left side go to the Listeners section

15.- Listeners Section
15.- Listeners Section

There, in the Virtual Host Mappings section create a new entry by clicking on the + button

16.- Creating a new VirtualHost on OpenLiteSpeed
16.- Creating a new VirtualHost on OpenLiteSpeed

And choose your Virtualhost as follows

17.- Virtual Host mapping
17.- Virtual Host mapping

Then click on the Save button.

Now you can restart OpenLiteSpeed to apply all these changes.

Testing the new VirtualHost on OpenLiteSpeed

Now on your server, create the corresponding folders. Both the Document Root folder and the log folder.

mkdir -p /usr/local/lsws/test.osradar.local/{html,logs}

Then, create a test file:

nano /usr/local/lsws/test.osradar.local/html/index.html

And add some message

Now try to open it from your browser. In this case, access it using the name of the VirtualHost.

18.- Virtualhost on OpenLiteSpeed
18.- Virtualhost on OpenLiteSpeed

So, the new Virtualhost is working.

Conclusion

Having Virtual hosts on OpenLiteSpeed is an easy matter thanks to the administrator interface the program has. As we have shown you in this post.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article