Introduction
OpenLiteSpeed is an open source web server characterized by high-performance, light-weight event-driven architecture, and Apache compatible rewrite rules. After installation on a VPS or Dedicated Server, it requires further configuration on its WebAdmin in preparation for installation of CMS websites and web applications.
In addition, it requires the installation of required packages i.e. the latest php version (i.e. 7.2 at the time of publication of this tutorial) for processing of web server requests and MySQL 8.0 for CMS or website database.
In this tutorial, we illustrate how to configure OpenLiteSpeed for CMS or Application installation by installing PHP 7.2 and MySQL 8.0 and configuring them with the OpenLiteSpeed web server on Ubuntu 18.04.
Pre-requisites:
- Already installed LiteSpeed Web Server on Ubuntu 18.04. You can accomplish this by following our tutorial –How to install Litespeed Web Server on an Ubuntu 18.04 VPS or Dedicated Server
- Basic understanding of Linux commands
- A non-root user with sudo privileges
Installing and Configuring PHP 7.2 with LiteSpeed
Overview
Litespeed completely supports PHP without any further configuration. However, Litespeed by-default comes with php5.6binary (/usr/local/lsws/lsphp) which can only be used for development environments and NOT RECOMMENDED for production environments. This is because of its minimal build.
PHP Support in Litespeed comprises two parts as follows:
1. PHP External Application: Litespeed does not have PHP inbuilt into it but rather hands over execution tasks to external PHP applications/executables. This enables for greater stability, security and managing simultaneous connections. The two PHP external applications used are:
- LSAPI (LiteSpeed SAPI – Server Application Programming Interface)
- FCGI SAPI (FastCGI SAPI – Server Application Programming Interface)
LSAPI acts as an interface between LiteSpeed and PHP. It’s HIGHLY RECOMMENDED as it’s specially built for Litespeed while it’s designed for high performance, faster and has more features than FCGI SAPI. LSAPI also binds for Python and Ruby.
2. Script Handler: Enables Litespeed to determine how the files will be directed to specific applications by mapping suffixes.
Note: Both the external application and script handler must be configured in the WebAdmin Console as is illustrated in the section that follows – Installing PHP 7.2 for Litespeed.
Installing PHP 7.2 for Litespeed
Add the repository for Litespeed PHP 7.2 by running the commands
$ sudo bash # wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash
Then install PHP 7.2 for Litespeed by running the command.
$ sudo apt install lsphp72 lsphp72-common lsphp72-mysql lsphp72-dev lsphp72-curl lsphp72-dbg lsphp72-tidy lsphp72-recode lsphp72-opcache -y
Finally create symbolic link for php7.2
$ sudo ln -sf /usr/local/lsws/lsphp72/bin/lsphp /usr/local/lsws/fcgi-bin/lsphp7
Configuring PHP 7.2 with LiteSpeed Web Server
At this stage, we change the PHP version being used by LiteSpeed from 5.6 to 7.2.
Log into LiteSpeed Web Server.
Go to Server Configuration > External App > Click Add button as shown in the figure below.
Then select the LiteSpeed SAPI App for the Type, then Click Next button as shown below.
Enter the following configurations as follows:
Name: lsphp72 Address: uds://tmp/lshttpd/lsphp.sock Notes: lsphp72forOpenLiteSpeed Max Connections: 35 InitialRequestTimeout(secs):60 RetryTimeout(secs):0 Command: $SERVER_ROOT/lsphp72/bin/lsphp
Then click the Save button in the right corner as shown below:
Since there are now two PHP versions in the web server, we should configure the Litespeed to only use PHP7.2 as follows.
Go to Script Handler > Click Edit button as shown below.
The select lsphp72 in the HandlerName and Click Save button as shown.
Click Graceful Restart button to apply the changes made as shown below.
Now Litespeed Web Server is using PHP7.2
Configure Port 80 on Litespeed Web Server
By-default the Litespeed web server is receiving HTTP requests on Port8088. But of course, you wouldn’t want your website visitors to be including port 8088 on the browser whenever they visit your site. Hence you need to change this to port 80.
Go to Listeners > Click View button for the Default Listener as shown.
Click the Edit button to edit the port as shown below.
Change the Port value from 8088 to 80 and Click Save button.
Click Graceful Restart button to apply the new changes.
Installing MySQL 8.0
MySQL is needed to provide the database infrastructure for your CMS or Web Application.
To install MySQL 8.0 in your Ubuntu 18.04 Server, follow our tutorial -How to Install MYSQL 8.0 and Create a Database on an Ubuntu 18.04 Linux VPS
Conclusion
Now that you’ve set up your setup and configured your Litespeed server environment, you can now install any CMS (e.g. WordPress, Drupal, Joomla), Web Application (e.g. Yii, Laravel), Ruby or Python Frameworks in the LiteSpeed Web Server.
The next steps are to learn the following:
How to Create VirtualHosts on LiteSpeed Web Server
How to Install and Configure WordPress on LiteSpeed Web Server
Check out these top 3 Linux hosting services
0