OpenLiteSpeed is a free and open-source web server edition of the LiteSpeed webserver Enterprise. It is an alternate solution for Apache web servers and is compatible with most features offered by Apache. It can be installed on many operating systems including, Linux, FreeBSD, and macOS. It combines speed, security, scalability, optimization, and simplicity in a single package. It is one of the fastest web servers and can handle thousands of concurrent connections.
In this post, we will explain how to install OpenLiteSpeed with MariaDB and PHP 8 on Debian 11.
Prerequisites
- A server running Debian 11.
- A root password is configured on your server.
Install OpenLiteSpeed
By default, the OpenLiteSpeed package is not included in the Debian 11 default repository. So you will need to install it from the OpenLiteSpeed installation script.
First, download the latest version of OpenLiteSpeed using the following command:
wget https://openlitespeed.org/packages/openlitespeed-1.7.14.tgz
Once the download is completed, extract the downloaded file using the command below:
tar -xvzf openlitespeed-1.7.14.tgz
Next, change the directory to the extracted directory and install the OpenLiteSpeed using the following command:
cd openlitespeed ./install.sh
Once the OpenLiteSpeed is installed, you will get the following output:
-e Installing, please wait... Admin SSL enabled! download comamnd is wget -nv -O 2021-12-10 15:37:08 URL:http://cyberpanel.sh/?ip [12] -> "https://vitux.com/usr/local/lsws/myip" [1] Generating a RSA private key ....................................................... ............................................................................. writing new private key to 'webadmin.key' ----- SSL host is [webadmin], use adminSSL download comamnd is wget -nv -O 2021-12-10 15:37:10 URL:http://www.litespeedtech.com/packages/lsphp5_bin/x86_64/lsphp5 [4902224/4902224] -> "https://vitux.com/usr/local/lsws/admin/fcgi-bin/admin_php" [1] admin_php downloaded. [Notice] We only have lsphp7 ready for Centos, Debian and Ubuntu. Generating key pair for web console login page, please wait ... Generating RSA private key, 512 bit long modulus (2 primes) .......... .. e is 65537 (0x010001) -e Updating webcache manager, please waiting ... Shared code library already meets minimum API version requirements. Done! -e Installation finished, Enjoy! -e Your webAdmin password is YzIyZDc0, written to file /usr/local/lsws/adminpasswd.
Create a Systemd Service File for OpenLiteSpeed
Next, you will need to create a systemd service file to manage the OpenLiteSpeed service. You can create it using the following command:
nano /etc/systemd/system/lsws.service
Add the following lines:
[Unit] Description=Openlitespeed web server After=network.target remote-fs.target nss-lookup.target [Service] Type=simple PIDFile=/tmp/lshttpd/lshttpd.pid KillMode=none PrivateTmp=false User=root Group=root ExecStart=/usr/local/lsws/bin/lswsctrl start ExecReload=/usr/local/lsws/bin/lswsctrl reload ExecRestart=/usr/local/lsws/bin/lswsctrl restart ExecStop=/usr/local/lsws/bin/lswsctrl stop ExecStatus=/usr/local/lsws/bin/lswsctrl status [Install] WantedBy=multi-user.target Alias=ols
Save and close the file then reload the systemd daemon to apply the configuration changes:
systemctl daemon-reload
Next, start and enable the OpenLiteSpeed service with the following command:
systemctl start lsws systemctl enable lsws
You can check the status of the OpenLiteSpeed using the following command:
systemctl status lsws
You will get the following output:
? lsws.service - Openlitespeed web server Loaded: loaded (/etc/systemd/system/lsws.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-12-10 15:49:57 UTC; 7s ago Main PID: 3168 (litespeed) Tasks: 4 (limit: 2341) Memory: 5.1M CPU: 69ms CGroup: /system.slice/lsws.service ??3168 openlitespeed (lshttpd - main) ??3173 openlitespeed (lscgid) ??3186 openlitespeed (lshttpd - #01) ??3187 lsphp Dec 10 15:49:57 debian11 systemd[1]: Started Openlitespeed web server. Dec 10 15:49:58 debian11 lswsctrl[3147]: [OK] litespeed: pid=3168.
Set the OpenLiteSpeed Administrative Password
Next, you will need to set an admin password to access the OpenLiteSpeed admin interface. You can set it using the following command:
/usr/local/lsws/admin/misc/admpass.sh
Set your administrative password as shown below:
Please specify the user name of administrator. This is the user name required to login the administration Web interface. User name [admin]: admin Please specify the administrator's password. This is the password required to login the administration Web interface. Password: Retype password: Administrator's username/password is updated successfully!
Next, restart the OpenLiteSpeed service to apply the changes:
systemctl restart lsws
Install MariaDB Server
You can install the MariaDB server and client package using the following command:
apt-get install mariadb-server mariadb-client -y
Once the MariaDB is installed, you can verify the MariaDB version with the following command:
mariadb --version
You will get the following output:
mariadb Ver 15.1 Distrib 10.5.12-MariaDB, for debian-linux-gnu (x86_64) using EditLine wrapper
Access OpenLiteSpeed Admin Interface
By default, the OpenLiteSpeed web interface listens on port 8088, and the admin interface listens on port 7080. You can check it using the following command:
ss -antpl
You should see the OpenLiteSpeed listening ports in the following output:
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 0 4096 0.0.0.0:7080 0.0.0.0:* users:(("litespeed",pid=3186,fd=21),("litespeed",pid=3168,fd=21)) LISTEN 0 80 127.0.0.1:3306 0.0.0.0:* users:(("mariadbd",pid=3935,fd=19)) LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=570,fd=3)) LISTEN 0 4096 0.0.0.0:8088 0.0.0.0:* users:(("litespeed",pid=3186,fd=23),("litespeed",pid=3168,fd=23)) LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=570,fd=4))
You can now access the OpenLiteSpeed admin interface using the URL https://your-server-ip:7080/login.php. You should see the following page:
Provide your admin username, password and click on the Login button. You should see the OpenLiteSpeed admin dashboard on the following page:
By default, the OpenLiteSpeed web server listens on port 8088. It is recommended to change it to port 80.
To change the listening port, click on the Listeners in the left pane and edit the listening port page. You should see the following page:
Click on the Edit icon. You should see the following page:
Change your default port to 80 and click on the Save icon and click on the Graceful restart button to apply the changes.
Install PHP 8.0 on OpenLiteSpeed
By default, OpenLiteSpeed comes with PHP 7.4. You can check the default PHP version by browsing the URL http://your-server-ip/phpinfo.php. You should see the PHP info page on the following screen:
To install the PHP 8.0, first install all the required dependencies using the following command:
apt-get install build-essential pkg-config openssl libssl-dev bison autoconf automake libtool re2c flex libxml2-dev libssl-dev libbz2-dev libcurl4-openssl-dev libjpeg-dev libfreetype6-dev libgmp3-dev libc-client2007e-dev libldap2-dev libmcrypt-dev libmhash-dev freetds-dev zlib1g-dev libncurses5-dev libpcre3-dev libaspell-dev libreadline6-dev librecode-dev libsnmp-dev libtidy-dev sqlite3 cmake zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libreadline-dev libffi-dev libsqlite3-dev libbz2-dev libonig-dev libzip-dev -y
Next, export the package config path using the following command:
export PKG_CONFIG_PATH=/usr/bin/pkg-config
Next, go to the OpenLiteSpeed admin console and click on the Tools => Compile PHP. You should see the following page:
Now, select PHP 8.0 from the drop-down menu and click on the Next button. You should see the following screen:
Choose any configuration option as per your requirements and click on the Next button. You should see the following page:
Next, open your terminal and run the following command to compile PHP 8.0.
/usr/local/lsws/phpbuild/buildphp_manual_run.sh
Once the PHP has been compiled, change the directory to fsgi-bin and create a symbolic link of PHP 8:
cd /usr/local/lsws/fcgi-bin ln -sf lsphp-8.0.7 lsphp8
You can also go back to the Admin console to see the installation notification:
Next, go to the Server Configuration => External App as shown below:
Click on the edit icon. You should see the following screen:
Change the name and address section with PHP 8 and click on the Save icon to apply the changes.
Next, click on the Script Handler tab and edit it. You should see the following screen:
Change the Suffixes and Handler name with PHP 8 and click on the Save icon then click on the Graceful restart button to apply the changes.
Now, open your web browser and verify the PHP version using the URL http://your-server-ip/phpinfo.php. You should see PHP 8 on the following screen:
Conclusion
Congratulations! You have successfully installed the OpenLiteSpeed web server with MariaDB and PHP 8.0 on Debian 11. You can now create a virtual host configuration file and host your first website on the OpenLiteSpeed web server.