Server Setup · 13 min read · Nov 24, 2025

Come Installare e Configurare OpenLiteSpeed Server insieme a MariaDB e PHP su Ubuntu 20.04

OpenLiteSpeed è una versione leggera e open-source del LiteSpeed Server sviluppato da LiteSpeed Technologies. Viene fornito con un pannello di amministrazione basato su WebGUI che lo rende diverso dagli altri server e più facile da gestire.

In questo tutorial, impareremo come installare OpenLiteSpeed Server su Ubuntu 20.04 insieme a PHP 7.4 e al server MariaDB.

Prerequisiti

  • Server web basato su Ubuntu 20.04.
  • Un account utente non root con privilegi sudo.

Aggiorna il tuo sistema.

$ sudo apt update
$ sudo apt upgrade

Passo 1 - Configurare il Firewall

Prima di iniziare con il tutorial, dobbiamo configurare il Firewall Semplice (UFW) che è solitamente abilitato per impostazione predefinita. Controlliamo prima lo stato del firewall.

Dobbiamo abilitare SSH, HTTP, HTTPS e le porte 7080, 8088 per il firewall.

$ sudo ufw allow OpenSSH
$ sudo ufw allow http
$ sudo ufw allow https
$ sudo ufw allow 7080/tcp
$ sudo ufw allow 8088/tcp

Controlla lo stato del firewall.

$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
80/tcp                     ALLOW       Anywhere                  
443/tcp                    ALLOW       Anywhere                  
7080/tcp                   ALLOW       Anywhere                  
8088/tcp                   ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
80/tcp (v6)                ALLOW       Anywhere (v6)             
443/tcp (v6)               ALLOW       Anywhere (v6)             
7080/tcp (v6)              ALLOW       Anywhere (v6)             
8088/tcp (v6)              ALLOW       Anywhere (v6)     

Se non funziona, avvia il firewall.

$ sudo ufw enable

Passo 2 - Installare OpenLiteSpeed

Ci sono varie versioni di OpenLiteSpeed che puoi installare. Le versioni consigliate sono della serie 1.6.x o 1.7.x al momento della scrittura di questo tutorial.

Utilizzeremo il Repository ufficiale di OpenLiteSpeed per il nostro tutorial che mantiene solo la versione 1.6.x.

Aggiungi la chiave del Repository di OpenLiteSpeed.

$ wget -qO - https://rpms.litespeedtech.com/debian/lst_repo.gpg | sudo apt-key add -

Aggiungi il Repository.

$ echo "deb http://rpms.litespeedtech.com/debian/ focal main" | sudo tee /etc/apt/sources.list.d/openlitespeed.list

Aggiorna il Repository.

$ sudo apt update

Installa OpenLiteSpeed

$ sudo apt install openlitespeed

Controlla lo stato del server.

$ sudo /usr/local/lsws/bin/lswsctrl status
litespeed is running with PID 21825.

Se non è in esecuzione, puoi avviarlo con il seguente comando.

$ sudo /usr/local/lsws/bin/lswsctrl start

Apri http://:8088 per accedere al tuo server web. Dovresti vedere la seguente pagina.

OpenLiteSpeed Default Page

Passo 3 - Installare PHP

Il server OpenLiteSpeed viene fornito con PHP 7.3 che è pre-abilitato. Ma vogliamo usare PHP 7.4, quindi installeremo la nostra copia.

Installa PHP 7.4 insieme ad alcuni pacchetti aggiuntivi.

$ sudo apt install lsphp74 lsphp74-common lsphp74-mysql lsphp74-curl

Verifica la tua installazione di PHP.

$ /usr/local/lsws/lsphp74/bin/php7.4 -v
PHP 7.4.5 (cli) (built: May  7 2020 23:08:38) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.5, Copyright (c), by Zend Technologies

Puoi controllare i moduli PHP abilitati.

$ /usr/local/lsws/lsphp74/bin/php7.4 --modules

Configureremo PHP per lavorare con OpenLiteSpeed più tardi.

Passo 4 - Installare MariaDB

Installa il server MariaDB.

$ sudo apt install mariadb-server

Avvia e abilita il servizio MariaDB.

$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb

Metti in sicurezza la tua installazione di MariaDB. Questo script imposterà la tua password di root, rimuoverà gli utenti anonimi, disabiliterà il login remoto come root e eliminerà le tabelle di test. Scegli una password forte e rispondi alle domande come descritto di seguito.

$ sudo mysql_secure_installation
[sudo] password for username: 

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB 
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Una volta fatto questo, puoi accedere alla shell di MySQL utilizzando il seguente comando.

$ sudo mysql -u root -p

Crea un database di test e un utente con permessi di accesso. Sostituisci testdb e testuser con nomi appropriati per la tua configurazione. Sostituisci password con una password forte.

CREATE DATABASE testdb;
CREATE USER 'testuser' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON testdb.* TO 'testuser';
FLUSH PRIVILEGES;

Esci dalla shell di MySQL.

exit

Passo 5 - Configurare OpenLiteSpeed

Configurare il Pannello di Amministrazione

Imposta le credenziali del pannello di amministrazione.

$ sudo /usr/local/lsws/admin/misc/admpass.sh
Please specify the user name of administrator.
This is the user name required to login the administration Web interface.

User name [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!

Puoi anche usare questo comando nel caso tu dimentichi i tuoi dettagli di accesso.

Per accedere al pannello di amministrazione, apri http://:7080.

Al primo accesso, il tuo browser darà avvisi dicendo che la tua connessione non è privata. Clicca su Avanzate e clicca su “Accetta il rischio e continua” (nel caso di Firefox) o “Procedi a (non sicuro) “ (nel caso di un browser basato su Chromium). Non vedrai più l’avviso.

Sarai accolto dalla seguente schermata.

OpenLiteSpeed Login Page

Cambiare la porta HTTP di nuovo a 80

Cambiamo la porta HTTP predefinita a 80. Accedi al tuo pannello di amministrazione su http://:7080 con le credenziali che hai appena creato.

Sarai accolto dalla seguente schermata.

OpenLiteSpeed Admin Home

Visita la sezione Listeners a sinistra. Vedrai i listener predefiniti con la porta 8080.

OpenLiteSpeed Listeners

Clicca sul pulsante Visualizza per vedere la configurazione dettagliata. Nella pagina successiva sotto Listener Default > General Page, clicca sull’icona Modifica e cambia la porta da 8080 a 80.

OpenLiteSpeed Default Listener

OpenLiteSpeed Listener Edit

Clicca su Salva e poi riavvia il server cliccando sul pulsante Riavvio Graduale.

Passo 6 - Configurare PHP

In questo passo, dobbiamo associare la nostra copia di PHP 7.4 con il server.

Clicca sulla sezione Server Configuration a sinistra e poi sulla scheda External App. Vedrai un’app LiteSpeed esistente per PHP 7.3. Creeremo la nostra app LiteSpeed per PHP 7.4. Puoi facilmente passare tra di esse in seguito se vuoi.

External Applications

Clicca sul pulsante Aggiungi per creare una nuova app. Per il tipo, seleziona LiteSpeed SAPI App e clicca su Avanti.

External App Configuration

Successivamente, aggiungi la configurazione qui sotto. Lascia tutti gli altri campi vuoti.

Name: lsphp74
Address: uds://tmp/lshttpd/lsphp.sock
Max Connections: 35
Environment: PHP_LSAPI_MAX_REQUESTS=500
             PHP_LSAPI_CHILDREN=35
             LSAPI_AVOID_FORK=200M
Initial Request Timeout (secs): 60
Retry Timeout : 0
Persistent Connection: Yes
Response Buffering: no
Start By Server: Yes(Through CGI Daemon)
Command: lsphp74/bin/lsphp
Back Log: 100
Instances: 1
Priority: 0
Memory Soft Limit (bytes): 2047M
Memory Hard Limit (bytes): 2047M
Process Soft Limit: 1400
Process Hard Limit: 1500

Clicca su Salva quando hai finito.

LiteSpeed SAPI App

Ora che abbiamo creato la nostra app basata su PHP 7.4, dobbiamo dire al server di iniziare a usarla.

Vai alla scheda Script Handler e modifica il gestore lsphp. Cambia il nome del gestore in lsphp74 dal menu a discesa.

Script Handler Definition

Clicca su Salva e poi riavvia il server cliccando sul pulsante Riavvio Graduale.

Per testare se il tuo PHP è stato cambiato correttamente, visita http:///phpinfo.php nel tuo browser.

PHP Info

Passo 7 - Configurare Virtual Host

Prima, dobbiamo creare le directory per il nostro virtual host.

$ sudo mkdir /usr/local/lsws/example.com/{html,logs} -p

La directory html conterrà i file pubblici e la directory logs conterrà i log del server.

Successivamente, apri la console di amministrazione e accedi alla sezione Virtual Hosts a sinistra e clicca sul pulsante Aggiungi.

Virtual Hosts Summary

Compila i valori come specificato

Virtual Host Name: example.com
Virtual Host Root: $SERVER_ROOT/example.com/
Config File: $SERVER_ROOT/conf/vhosts/$VH_NAME/vhconf.conf
Follow Symbolic Link: Yes
Enable Scripts/ExtApps: Yes
Restrained: Yes
External App Set UID Mode: Server UID

Virtual Host Settings

Clicca sul pulsante Salva quando hai finito. Riceverai il seguente errore perché il file di configurazione non esiste ancora. Clicca sul link per creare il file di configurazione.

Virtual Host Configuration

Clicca di nuovo sul pulsante Salva per completare la creazione del Virtual Host.

Una volta creato il virtual host, vai su Virtual Hosts -> Scegli Virtual Host(example.com) -> Generale e modifica la configurazione come indicato.

Document Root: $VH_ROOT/html/
Domain Name: example.com
Enable Compression: Yes

Virtual Host General Section

Clicca sul pulsante Salva quando hai finito. Successivamente, dobbiamo impostare i file indice. Clicca sul pulsante di modifica contro i file indice nella sezione Generale. Imposta le seguenti opzioni.

Use Server Index Files: No
Index files: index.php, index.html, index.htm
Auto Index: No

OpenliteSpeed Index Files

Clicca su Salva quando hai finito. Successivamente, dobbiamo scegliere i file di log. Vai alla sezione Log e clicca su Modifica contro Virtual Host Log e compila i seguenti valori.

Use Server’s Log: Yes
File Name: $VH_ROOT/logs/error.log
Log Level: ERROR
Rolling Size (bytes): 10M

Virtual Host Log

Puoi scegliere il Log Level come DEBUG se sei su una macchina di produzione/sviluppo.

Clicca su Salva e poi clicca sul segno più nella sezione Access Log per aggiungere una nuova voce. Compila i seguenti valori.

Log Control: Own Log File
File Name: $VH_ROOT/logs/access.log
Piped Logger: Not Set
Log Format: Not Set
Log Headers: Not Set
Rolling Size (bytes): 10M
Keep Days: 30
Bytes log: Not Set
Compress Archive: Yes

OpenliteSpeed Access Log

Clicca su Salva quando hai finito. Successivamente, dobbiamo configurare Access Control nella sezione Sicurezza. Imposta i seguenti valori.

Allowed List: *
Denied List: Not set

OpenliteSpeed Access Control

Clicca su Salva quando hai finito. Successivamente, dobbiamo impostare la Script Handler Definition. Imposta i seguenti valori.

Suffixes: php
Handler Type: LiteSpeed SAPI
Handler Name: [Server Level]: lsphp74

Script Handler Definition

Successivamente, dobbiamo impostare il Rewrite Control nella sezione Rewrite. Imposta i seguenti valori.

Rewrite Control

E infine, dobbiamo impostare i Listener. Vai alla sezione Listeners e clicca sul pulsante Visualizza contro Default Listener. Poi, clicca sul pulsante Aggiungi contro Virtual Host Mappings per aggiungere una nuova mappatura e imposta i seguenti valori.

Clicca su Salva quando hai finito. Ora, clicca sul pulsante Riavvio Graduale per applicare tutte le modifiche sopra e riavviare il server.

Passo 8 - Configurare SSL

Impostare SSL in OpenLiteSpeed richiede di impostare due certificati. Un certificato autofirmato per l’intero server e un certificato specifico per il sito Let’s Encrypt.

Creiamo prima il Certificato Autofirmato.

$ openssl req -x509 -days 365 -newkey rsa:4096 -keyout key.pem -out cert.pem -nodes
Generating a RSA private key
..++++
......................++++
writing new private key to 'key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

Puoi premere invio attraverso tutti i campi e lasciarli vuoti.

I certificati sono ora memorizzati nella directory /home/user. Avremo bisogno di queste informazioni più tardi.

Per utilizzare Let’s Encrypt, dobbiamo installare lo strumento Certbot.

$ sudo apt install certbot

Ottieni il certificato SSL.

$ sudo certbot certonly --webroot -w /usr/local/lsws/example.com/html/ -d example.com

Segui il prompt interattivo.

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]
Starting new HTTPS connection (1): acme-v01.api.letsencrypt.org

-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree
in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A

-------------------------------------------------------------------------------
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
-------------------------------------------------------------------------------
(Y)es/(N)o: N
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Using the webroot path /usr/local/lsws/example.com/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example/fullchain.pem. Your key file has 
   been saved at:
   /etc/letsencrypt/live/linode.nspeaks.com/privkey.pem Your cert will
   expire on 2020-09-04. To obtain a new or tweaked version of this
   certificate in the future, simply run certbot again. To
   non-interactively renew *all* of your certificates, run "certbot
   renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Ora apri la console di amministrazione e vai a Listeners >> Aggiungi Nuovo Listener e aggiungi i seguenti valori.

Listener Name: SSL
IP Address: ANY
Port: 443
Secure: Yes

SSL Listener

Clicca su Salva quando hai finito. Successivamente, vai alla sezione Virtual Host Mappings sotto il Listener SSL cliccando su SSL, clicca sul pulsante Aggiungi e compila i seguenti valori.

Virtual Host: example.com
Domains: example.com

Clicca su Salva quando hai finito.

Successivamente, vai a Listeners >> SSL Listener >> SSL Tab >> SSL Private Key & Certificate (pulsante Modifica) e compila i seguenti valori per il certificato autofirmato che abbiamo creato prima.

Private Key File: /home/user/key.pem
Certificate File: /home/user/cert.pem
Chained Certificate: Yes

Self Signed SSL Key and Certificate

Successivamente vai a Virtual Hosts >> example.com >> SSL Tab >> SSL Private Key & Certificate (pulsante Modifica) e compila i seguenti valori con il certificato Let’s Encrypt.

Private Key File: /etc/letsencrypt/live/example.com/privkey.pem
Certificate File: /etc/letsencrypt/live/example.com/fullchain.pem
Chained Certificate: Yes

Let's Encrypt SSL Key and Certificate

Clicca su Salva quando hai finito.

Riavvia il server cliccando sul pulsante Riavvio Graduale.

Passo 9 - Testare il Sito

Crea un file di test nella tua directory html.

$ sudo nano /usr/local/lsws/example.com/html/index.php

Incolla il seguente codice nell’editor Nano.



    

OpenLiteSpeed Server Install Test

Hello,

'; // Define PHP variables for the MySQL connection. $servername = "localhost"; $username = "testuser"; $password = "password"; // Create a MySQL connection. $conn = mysqli_connect($servername, $username, $password); // Report if the connection fails or is successful. if (!$conn) { exit('

Your connection has failed.

' . mysqli_connect_error()); } echo '

You have connected successfully.

'; ?>

Visita il tuo sito su https://example.com in un browser e dovresti vedere la seguente pagina.

OpenLiteSpeed Site Test

Questo è tutto per questo tutorial. Se hai domande, scrivile nei commenti qui sotto.

Share: X/Twitter LinkedIn

Ricevi i nuovi post nella tua casella di posta.

Nessuno spam. Disiscriviti in qualsiasi momento.