DirectAdmin

This guide will teach you how to convert a DirectAdmin shared-hosting server to an optimized high-performance DirectAdmin + LiteSpeed Enterprise Web Server.

You will learn how to best utilize LiteSpeed Web Server, LiteSpeed Cache, and LiteSpeed Cache Manager for DirectAdmin. The steps outlined in the guide are just that: outlines. They should be used in conjunction with the more detailed materials in the links provided. In other words, if a section of this guide is not perfectly clear, but there is a link attached to that section, please check the link. There are many things that are too complicated to be explained fully in this short document.

Introduction

LiteSpeed provides one-stop web-acceleration solutions that embrace and advance cutting-edge technologies. Products include LiteSpeed Web Server, LiteSpeed Web ADC load balancer, cache solutions, and OpenLiteSpeed open source web server, among others.

LiteSpeed Web Server

LiteSpeed Web Server offers a combination of cutting-edge features, outstanding scalability, best-in-class performance, Apache compatibility and application-level cache acceleration.

LiteSpeed Web Server with DirectAdmin and CustomBuild

LiteSpeed Web Server is a drop-in replacement for Apache which provides high performance with LSCache solutions, and uses many fewer resouces. This script uses DirectAdmin's CustomBuild Plugin to install LiteSpeed Web Server.

Prepare for the Installation

Obtain a License

Visit the LiteSpeed store to obtain a license.

You can get a Free Starter License if you are planning to host only a single domain and have a server with less than 2GB RAM. Other Licenses can also be purchased from the same link. If you are looking for a trial license and have a server with more than 2GB RAM and multiple domains, you can skip this step.

If you need help with choosing a License, visit our wiki.

Verify SSH and sudo Permission on Server

LiteSpeed Web Server requires you to have full root access to the server for the installation.

Remove any Previous Apache Replacements or Reverse Proxies

The CustomBuild Plugin will disable all the other Webservers(Apache/Nginx) installed on the server. If you have a custom setup, please manually uninstall any reverse proxies like Nginx over Apache or Nginx/Varnish before installing LiteSpeed Web Server.

Ensure all Websites are Working Well on Apache

Before installing LiteSpeed, you should make sure that your DirectAdmin installation is working fine with Apache. If this is a brand new server, you can add a test domain and remove it later.

Ensure that TCP 80,443 and UDP 443 are open in Firewall Configuration

In addition to TCP 80 and TCP 443, LiteSpeed uses UDP 443 for QUIC, which is one of the most popular features of LiteSpeed, and it and provides great benefits to your websites.

TCP 7080 is also used by LiteSpeed for its WebAdmin Console, and it requires a username and password to log in, which you will set during the installation. You should keep this port open to Administrative IP's only.

Installation

There are two ways to install LiteSpeed Web Server on your system: Detailed installation, and quick/automated installation.

Detailed Installation

This method is recommended if you are installing LiteSpeed for the first time. We will discuss each and every option that is presented during the installation process in detail.

LiteSpeed installation is easy and straightforward. Log in to your SSH server and run the following command, replacing your_serial_no with your License key:

bash <( curl https://get.litespeed.sh ) your_serial_no

This script detects your environment and downloads only the required dependencies and installation data from our servers. Depending on the environment, the script asks you for input to various questions. Finally, it installs LiteSpeed Web Server.

Tip

To use this script with a trial license, just replace your_serial_no with the word TRIAL (in all capitals), like so:

bash <( curl https://get.litespeed.sh ) TRIAL
This will automatically request a trial license for your server and install LiteSpeed Web Server on it. If you see an error while using the Trial License, Please refer to the FAQ.

Once you've started the script, it will detect that your installation is using DirectAdmin and will ask your input with the following prompts:

Could not find an lsws.options file

Could not find an lsws.options file. We will ask you for your preferred settings instead, but for automated bulk provisioning, you may want to exit and create an lsws.options file. Continue Installer(Y/N) ?

This is expected since this is the detailed installation process. lsws.options is for quick/automatic installation.

Press Y and Enter to proceed.

Default PHP version

php_version_default. Available options are - 7.2, 7.1, 7.0, 5.6.

This will be the first and default PHP version on your server.

Second PHP version

php_version_second. Available options are - 7.2, 7.1, 7.0, 5.6, no.

This will be the second PHP version on your server. Just enter no(without caps) if you would like to not install a second PHP version.

Third PHP version

php_version_third Available options are - 7.2, 7.1, 7.0, 5.6, no.

This will be the thrid PHP version on your server. Just enter no(without caps) if you would like to not install a second PHP version.

Fourth PHP version

php_version_fourth. Available options are - 7.2, 7.1, 7.0, 5.6, no.

This will be the fourth PHP version on your server. Just enter no(without caps) if you would like to not install a second PHP version.

After all of the values have been entered, the script will install LiteSpeed Web Server on your DirectAdmin server.

Once the installation is complete, you should see the following success message with a randomly generated password. You should save this password in a safe place. You can also change it later.

If you encounter any problems during the installation, feel free to create a ticket with us, and we will be happy to help.

Quick/Automated Installation

This method uses shortcuts to automate the installation and deployement of LiteSpeed in the fastest possible way on DirectAdmin servers.

In most situations, running the installer script manually is sufficient. However, it is possible to automate the process for bulk provisioning. To do this you can create a lsws.options file and upload it to your organization's internal repo. This will allow the installer to pick up installation options directly from the file and will not ask for input from the user.

A default lsws.options file will looks like this:

php_version_default="7.2"
php_version_second="7.1"
php_version_third="no"
php_version_fourth="no"
If you do not understand what the other options mean, please go through the detailed installation process once.

You can create lsws.options and keep it on your local network for bulk provisioning, at a URL like yourlink.com/yourinternalrepo/lsws.options and then run the following command:

curl -o lsws.options yourlink.com/yourinternalrepo/lsws.options && bash <( curl https://get.litespeed.sh ) your_serial_no

Note

yourlink.com/yourinternalrepo/lsws.options is the link to your personalized lsws.options file which should be accessible to your servers.

lsws.options is the location of the lsws.options file. If you're running the installer from the same directory as your lsws.options file, Its fine to leave it exactly like that.

your_serial_no is the license key for LiteSpeed Web Server. You can also use TRIAL if you want to request a Trial License. If you see an error while using the Trial license, Refer to the FAQ.

After Installation

Verify is LiteSpeed Web Server is Running

Navigate to DirectAdmin's Service Manager to check if LSWS is running.

Set Up Cache Root and Enable LiteSpeed Cache Throughout the Server

Cache Storage Settings

Set Server-Level Cache Root

Add the following lines to the /etc/httpd/conf/extra/httpd-includes.conf file.

<IfModule Litespeed>
CacheRoot /home/lscache/
</IfModule>

Note: It is recommended that you set the server-level cache root to /home/lscache/ or a disk partition with enough space.

Set Virtual-Host-Level Cache Root for all Virtual Hosts

Create a /usr/local/directadmin/data/templates/custom/cust_httpd.CUSTOM.2.pre file

<IfModule Litespeed>
  CacheRoot lscache
</IfModule>

This is done to set each Virtual Hosts' cache directory to its home directory (/home/<user>/lscache).

Apply these changes to all Virtual Hosts by running the following command:

cd /usr/local/directadmin/custombuild
./build rewrite_confs

LiteSpeed Web Server will be restarted after running above commands.

Set up DirectAdmin LiteSpeed Plugin to manage Cache Installations

Download the DirectAdmin Plugin .tgz file from here.

Log into the DirectAdmin Panel with the admin username, or with a user which has admin-level authorizations. After you're logged in, navigate to the Plugin Manager section. It is usually located at https://your-directadmin-server:2222/admin/plugin-manager.

Click Add New.

Click Upload, and select the .tgz file you downloaded. In the Password section, Enter your DirectAdmin user's password. Click Install.

Once the installation is complete, you should be see the Litespeed Webserver Plugin option listed among Extra Features.

Using the Plugin

From within the LSCWP Version Manager section, select the WordPress plugin version you'd like to install on all WordPress websites hosted on the server.

From the Manage Cache Installations section, click Scan to search the entire server for existing WordPress installations. You can also enable or disable cache for individual websites from here.

From the Mass Enable/Disable Cache section, you can Enable or Disable Cache on all scanned WordPress installations throughout the server. This is safe because it automatically skips the WordPress installations which have a different cache plugin installed.

This plugin can also be used to access the Litespeed WebAdmin Console to manage license-based functions.

Set up ModSecurity Rules for LiteSpeed with DirectAdmin

Run the following commands to enable ModSecurity and install rules automatically.

cd /usr/local/directadmin/custombuild
./build set modsecurity yes
./build set modsecurity_ruleset comodo
./build modsecurity

Verify LiteSpeed is Running Correctly on Websites and LiteSpeed Cache is Working

Now that the installation and enablement process for your server has been completed, it's time to verify that your websites are running on LiteSpeed and that LiteSpeed Cache is working correctly on your WordPress websites.

Select User Level and Click Domain Setup and open any customer’s website, and check its headers, like so:

The headers should show Server as LiteSpeed and X-LiteSpeed-Cache as hit or miss.

The X-LiteSpeed Cache header will only be shown on Websites which have LiteSpeed Cache enabled at that moment. Other websites will show Server as LiteSpeed only, and will continue to use benefits provided by LiteSpeed without caching.

Headers can be checked by using browser extensions.

Set Up Multi PHP Version

Select User Level, click Domain Setup, and select any website from the list. Head over to the PHP Version Selector option and select the desired PHP Version. Press the Save button.

CloudLinux Selector PHP version

  1. From the CageFS User Manager add a user as Enabled
  2. From the LVE Manager set the default PHP version to Native
  3. Log in at the user level. Choose Select PHP version as the version you want to use

Frequently Asked Questions

What if I see a failure message when I request a TRIAL license during installation?

We track all licenses by Server IP. If your server has been given a trial license before, it won't be able to request another automatically. We will, however, reset it by request for eligible servers. To request another trial, please contact us.

Will LiteSpeed automatically sync all of my current and new domains?

LiteSpeed is a full-service drop-in replacement for Apache on DirectAdmin servers. As a result, it will automatically pick up all of the domains hosted on your server. It will also work with any new domains without error.

Will LiteSpeed match all of my PHP installations?

LiteSpeed will install PHP according to the options selected during installation, or it will pick up options from the lsws.options file in the installation directory, if available.

How do I troubleshoot errors with LiteSpeed Web Server?

If you see an error on your websites while using LiteSpeed, Please refer to the LiteSpeed Wiki

How do I change my WebAdmin Port?

Some services like Bitninja also use TCP 7080, which is LiteSpeed WebAdmin Console's default port. Without it, LiteSpeed will not start. If 7080 is assigned to another service, you can change WebAdmin's port like so: Open /usr/local/lsws/admin/conf/admin_config.xml using your preferred editor. Change the value of Listener from 7080 to your desired available port.

How do I change the LiteSpeed WebAdmin Console Password?

You may change LiteSpeed's WebAdmin Console password, like so:

cd /usr/local/lsws/admin/misc
./admpass.sh

How do I add the LSCache plugin to WordPress websites?

Log in to the WordPress Dashboard and install the plugin directly from the Wordpress Plugin Directory

How do I install LiteSpeed Cache extensions on other CMS's?

LiteSpeed Cache supports various other CMS's, like Joomla and Drupal. Please visit our website for more information on the CMS'es supported by LiteSpeed, and for instructions for downloading and installing each.

How do I utilize LiteSpeed Cache on CMS's where no plugin exists?

Please check out our no-plugin setup guidelines on our wiki.

What happens if my LiteSpeed license Domain/RAM Limit is crossed? or if my license expires?

In a case where your LiteSpeed license is deemed invalid (due to exceeding limits or reaching the exiration date), your system will automatically switch to Apache. (This is true as of LSWS v5.3.5)

Which license should I choose?

Visit our website for a complete guide to choosing a license. Don't worry if you are not sure what level will be right for your needs. You can upgrade or downgrade your license at any time.

I want to use DirectAdmin with OpenLiteSpeed instead, How to do it?

DirectAdmin does support OpenLiteSpeed as well and can be installed using instructions here

Info

Installation for LiteSpeed Web Server on DirectAdmin is done using DirectAdmin's CustomBuild Plugin. Please get in touch directly with DirectAdmin for any CustomBuild support-related queries. For any LiteSpeed-related queries, please get in touch with us at support@litespeedtech.com.