Home Server Boost Performance! Install OpenLiteSpeed on DirectAdmin

Boost Performance! Install OpenLiteSpeed on DirectAdmin

Supercharge Your DirectAdmin Server! Replace Apache with OpenLiteSpeed for lightning-fast website loading times. Easy step-by-step guide for a smooth transition


It is expected to be written as a series of articles. This article is the first chapter of the series:

First popularize OpenLiteSpeed(hereinafter referred to as OLS) related knowledge, OLS is LiteSpeed ​​Technologies Inc.An open source web server produced by the company, the commercial version of the web server LiteSpeed ​​Web Server, Enterprise edition(LSWS for short) has super performance and is almost the strongest on the earth in various tests and actual use. Taking the most common WordPress platform as an example, use the LSWS server and turn on their cache optimization plug-in developed specifically for WP. LSCache for WPFinally, the processing capacity per second far exceeds that of other plug-ins, as shown below:

How DirectAdmin panel uses OpenLiteSpeed ​​instead of default Apache

And both the commercial version and the open source version support many of the latest technologies, such as HTTP/2 / HTTP/3 / SPDY / QUIC support, making the website open quickly.

But the biggest disadvantage of the commercial version of LSWS is that it is expensive?, we do not consider the commercial version here. Fortunately, the company has also released an open source version of OLS. I believe many people have installed it and experienced it. However, OLS is very unfriendly in use. Compared with the LSWS commercial version, it has emasculated the most important function: fully compatible with Apache. httpd.conf file and .htaccess file. The difference between the open source version and the commercial version can be found on the official pageAs shown in the red circle in the figure below, OLS lacks two functions that DirectAdmin needs most.

The configuration file of the LSWS commercial version is compatible with Apache, while the configuration file of OLS uses a private format, which leads to a very serious problem. The existing popular web server operation panels such as cPanel, DirectAdmin and Plesk are all based on Apache. Some The built-in scripts are also processed based on the Apache format, so we have not been able to perfectly experience installing the free and open source OLS web server on CP or DA before.

After DirectAdmin is updated to version 1.57, began to support the installation of OLS, but there were many inexplicable bugs during my experience at that time, and I stopped using it later. In the past two days, I changed the server and reinstalled DirectAdmin. When optimizing the server, I found that the DA official has solved the compatibility issues mentioned above through hard work, so I also tried to install the open source OLS. The following is The process of installing OLS to replace Apache.

1. Requirements: The DA panel must be upgraded to the latest version ( supported by 1.57 and above), but I advise you not to try the latest version) and use the DirectAdmin built-in Custombuild Also upgraded to the latest version 2.0,Excuting an order:

cd /usr/local/directadmin
mv custombuild custombuild_1.x
wget -O custombuild. tar . gz http://files.directadmin.com/services/custombuild/2.0/custombuild.tar.gz
tar xvzf custombuild. tar . gz
cd custombuild

According to official documentation To do this, set the webserver to OpenLiteSpeed ​​in custombuild, and change the PHP mode to lsphp, which is only supported by OLS . Then start compiling OLS and lsphp, and finally rewrite the DA configuration file. The compilation process takes a long time, so please wait patiently.

./build update
./build set webserver openlitespeed
./build set mod_ruid2 no
./build set php1_mode lsphp
./build openlitespeed
./build rewrite_confs

Basically if you only need a php version, this is where you go.

cd /usr/local/directadmin/custombuild
./build update
./build set webserver openlitespeed
./build set mod_ruid2 no
./build set php1_release 7.3
./build set php2_release 7.2
./build set php3_release 7.1
./build set php4_release 5.6
./build set php1_mode lsphp
./build set php2_mode lsphp
./build set php3_mode lsphp
./build set php4_mode lsphp
./build rewrite_confs

I have specified the version numbers of the four PHPs to be installed, and the setting modes are all lsphp. After executing the command, after a long wait, I saw a prompt as shown below, and the installation was completed.

The remaining step is also the most important step, because in order to distinguish it from the commercial version, the open source version of OLS restricts the function of real-time reading of .htaccess files. It only reads .htaccess once when OLS starts , forcing Please use the commercial version. The next step is to have the system regularly scan the .htaccess files in the root directory of all user websites. If any changes are found, OLS will be automatically restarted to circumvent restrictions.

We use the system’s cronjob function to add a scheduled task to the system, enter the /etc/cron.d/ directory, create a new file named openlitespeed_htaccess_scan, and write the following code into the file.
The following code means to scan the .htaccess files in the root directory of all user websites and the deepest 2-level directory every three minutes for changes. If there are changes, restart the OLS service. You can change “*/3” to 5 or other intervals. , does not need to be too small to avoid excessive load. “maxdepth 2” is basically enough. Searching for too many layers will cause serious performance problems.

cd /etc/cron. d /
touch openlitespeed_htaccess_scan
echo "*/3 * * * * root if ! find /home/*/domains/*/*_html/ -maxdepth 2 -type f -newer /usr/local/lsws/cgid -name '.htaccess' -exec false {} +; then /usr/local/lsws/bin/lswsctrl restart; fi" > openlitespeed_htaccess_scan

At this point, the process of installing OpenLiteSpeed ​​to replace Apache on the DA panel is over, and you can now start the experience.
The next article writes about the question “How to display the visitor’s real IP if OpenLiteSpeed ​​uses a CDN such as CloudFlare”.


Please enter your comment!
Please enter your name here