
Doing Something With a Server: OpenLitespeed Configuration
- Written by John
- Sep 7th, 2018
You may be thinking, “What is OpenLitespeed”, which was my first thought when I first came across it. Ever since I found Litespeed/OpenLitespeed it has been my first choice in web server software, despite its learning curve. Another reason for choosing OpenLitespeed, it is generally a less used web server software compared to Apache and Nginx and there’s a lot less documentation or articles out there. This article is the result of a couple of years of using OpenLitespeed. Hopefully, it will help you implement OpenLitespeed much easier than when I first installed it.
At the time of writing this article, v1.4.39 was the latest version available.
Let’s get started with the configuration of OpenLitespeed.
Installing OpenLitespeed
When we completed our OS Configuration we added the Litespeed repo to our OS. We will use this to install OpenLitespeed v1.4.39. When newer versions are available to download you can use the same repo to update it. Run the following command to install OpenLitespeed.
sudo yum install openlitespeed -y
When installing OpenLitespeed you can specify a specific version you want to install if you don’t want the latest version.
sudo yum install openlitespeed-1.4.39 -y
Please note: as of 21/09/18 Litespeed have released version 1.4.39 which fixed the SSL issues in 1.4.35 – 1.4.38. Please avoid these versions if you require SSL.
Prerequisites
Before we can start to use OpenLitespeed we need to install some prerequisite packages. These packages are for compiling, packages inside the admin console mainly. These packages are also used to compile OpenLitespeed from source if that’s your thing.
sudo yum install gcc gcc-c++ make autoconf glibc rcs
sudo yum install pcre-devel openssl-devel expat-devel geoip-devel zlib-devel udns-devel
Prerequisites from https://openlitespeed.org/kb/installation-from-source-code/
Please note: certain versions of Amazon Linux do not have udns-devel as a package. The udns package is required to compile OpenLitespeed from source. Follow this article if you are wanting to compile OpenLitespeed from source.
Configuring OpenLitespeed
Folder Creation
Before we configure OpenLitespeed we need to create our folders where we will be placing our web files. Generally, these files are placed in /var/www/html but they can be placed anywhere you require on the server. I will be creating a folder for the logs too. Let’s create the folder(s) for the web files.
sudo mkdir /var/www/html -p
sudo mkdir /var/log/ols/html -p
Now we need to ensure that the nobody user and group is the owner of the folders for the web files. The nobody user and group is what OpenLitespeed runs off by default.
sudo chown -hR nobody:nobody /var/www/html
Startup and Admin Config
We need to ensure OpenLitespeed starts when our server or OS boots up. We also need to change the default admin account for the admin interface.
sudo chkconfig lsws on
sudo /usr/local/lsws/admin/misc/admpass.sh
Input a username and password to use for the admin console.
Let’s startup OpenLitespeed and see if we can navigate to it in your browser on port 8088.
sudo service lsws start
If you do not have a hostname for your server, or you’re hosting the server on your local machine, you’ll need to use the IP address of that server/machine.
Going forward I’ll be using dswas.goggs.eu domain.
Installation Issues
I only came across one issue which was easy to fix. When starting OpenLitespeed it would take about 20 seconds to finish starting but the server would not start. I ran the OpenLitespeed application from the direct file.
sudo /usr/local/lsws/bin/lswsctrl start
I then received the error.
After a bit of Google’ing I found an article, that was not related to OpenLitespeed or a web server for that matter, that stated to find and move the libpcre.so.1 file to the correct location, effectively renaming it. I knew I had the correct packages installed so I was able to find it and replace it with the following commands.
sudo find / -name libpcre*
sudo ln -s /usr/lib64/libpcre.so.1 /usr/lib64/libpcre.so.0
Now I can start the OpenLitespeed server with the normal command
sudo service lsws start
Configuring the Server
This part is the fun bit (not really) but it’s what will get your server up and running. Whilst we’re configuring it to use the web files that we will store in /var/www/html we need to ensure we are securing the server as well (there will be more of this when we start to use Lets Encrypt).
Jump into the admin console (http://IP-or-HOSTNAME:7080). It should look something like this.
On the left you have your navigation panel. There are 3 main sections we will be using mostly throughout this series.
- Server Configuration
- Listeners
- Virtual Hosts
Let’s start with Server Configuration. Items in this section are to configure the actual server itself, the backend if you will. There are some configurable items that required to be turned on or configured here if you want to use them. I will be using dswas.goggs.eu as the hostname for this server. I will be listing any settings that I change and I will do my best to display these settings clearly.
General > Server Process
- Server Name: dswas.goggs.eu
- Number of Workers: 1 – usually set this for how many cores/threads are available for your server
General > General Settings
- Enable GeoLocation Lookup: Yes
- Administrator Email: <YOUR_EMAIL>
Tuning > Connection
- Smart Keep-Alive: Yes
Tuning > SSL Global Settings
- Enable Session Cache: Yes
- Enable Session Tickets: Yes
Security > File Access
- Check Symbolic Link: Yes
- Force Strict Ownership: Yes
Time to move onto Listeners. Listeners are what “listens” for traffic on specific ports, hostnames or IP addresses.
Listeners > General > Address Settings
- Listener Name: http
- Port: 80
If you have a multi-core CPU you can select how many cores or threads are assigned to OpenLitespeed. You can set this under Binding.
Virtual Hosts > Add
- Virtual Host Name: dswas.goggs.eu
- Virtual Host Root: /var/www/html
- Config File: $SERVER_ROOT/conf/vhosts/$VH_NAME/$VH_NAME.conf
- Enable Scripts/ExtApps: Yes
- Restrained: Yes
- Smart Keep-Alive: Yes
Click on the save icon. You will get an error for the Config File as the config file for the virtual host does not exist. Click CLICK TO CREATE to create a config file and click on the save icon again.
Go back into the http listener and under Virtual Host Mappings click on Add. In the dropdown for Virtual Host select the virtual host that you’ve just created. Under Domains type in the domain that you are going to use. Click on the save icon.
Under the http listener, you will now see an additional Virtual Host Mapping.
We need to finish the rest of the configuration for our virtual host. Go back into Virtual Hosts.
General > General
- Document Root: $VH_ROOT
- Domain Name: dswas.goggs.eu
- Domain Aliases: dswas.goggs.eu
- Administrator Email: <EMAIL>
- Enable Compression: Yes
- Enable GeoLocation Lookup: Yes
General > Index Files
- Use Server Index Files: Yes
- Index Files: index.php, index.html
Log > Virtual Host Log
- Use Server’s Log: No
- File Name: /var/log/ols/error.log
Log > Access Log
- File Name: /var/log/ols/access.log
- Log Headers: Check all except None
Restart OpenLitespeed in the admin console. Go to dashboard and you should have no errors in the Server Error Log. If you get any errors go back over the config and amend where required.
Placing Your Web Files
Now that we have the basic configuration completed we can start to place our web files into /var/www/html. This directory on the host is the root location where all of the web files for the configured vhost need to be placed.
If you don’t have any web files available to you copy the below code, placing it into an index.html file located in /var/www/html. This will allow you to see if everything is configured correctly. Once done you can navigate to your hostname.
As an example go to DSWAS to view how the code will display.
See the Pen DSWAS: My First Webpage by John ( @jgoggs ) on CodePen.