Installazione LAMP · 5 min read · Sep 26, 2025

Come installare il LAMP Server Stack su Ubuntu 22.04

LAMP è una piattaforma di sviluppo web gratuita, open-source e una delle più popolari che consente agli sviluppatori web di costruire, distribuire e gestire siti web e applicazioni online. Utilizza quattro componenti open-source: Linux come sistema operativo, Apache come server web, MySQL come sistema di gestione di database relazionali e PHP/Perl/Python come linguaggio di scripting orientato agli oggetti. Lo stack LAMP è la scelta principale di tutti gli sviluppatori web perché è sufficiente per ospitare una vasta gamma di framework per siti web, come Joomla, Drupal e WordPress.

Caratteristiche

  • Un server LAMP è gratuito e open-source, quindi chiunque può scaricare il suo codice sorgente e apportare modifiche e miglioramenti, migliorando le sue prestazioni complessive.
  • È personalizzabile. Puoi sostituire ogni componente con un’altra soluzione open-source per soddisfare le esigenze specifiche dell’applicazione.
  • Ha una comunità più ampia, quindi puoi trovare supporto facilmente.
  • È uno stack maturo che è facile da configurare.

Questo post ti mostrerà come installare il server LAMP su Ubuntu 22.04.

Requisiti

  • Un server che esegue Ubuntu 22.04.
  • Minimo 1 GB di RAM e 5 GB di spazio su disco rigido.
  • Una password di root configurata sul server.

Installa Apache su Ubuntu 22.04

Il server web Apache è un componente principale dello stack LAMP. Per impostazione predefinita, il pacchetto del server web Apache è incluso nel repository predefinito di Ubuntu 22.04. Puoi installarlo facilmente eseguendo il seguente comando:

apt-get install apache2 -y

Una volta installato il server Apache, avvia e abilita il servizio web Apache utilizzando il seguente comando:

systemctl start apache2  
systemctl enable apache2

Ora puoi controllare lo stato del servizio Apache utilizzando il seguente comando:

systemctl status apache2

Otterrai lo stato di Apache nel seguente output:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-04-29 07:27:44 UTC; 4s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 923 (apache2)
      Tasks: 55 (limit: 4630)
     Memory: 5.1M
        CPU: 56ms
     CGroup: /system.slice/apache2.service
             ??923 /usr/sbin/apache2 -k start
             ??924 /usr/sbin/apache2 -k start
             ??925 /usr/sbin/apache2 -k start

Apr 29 07:27:44 ubuntu systemd[1]: Starting The Apache HTTP Server...

Per controllare la versione di Apache, esegui il seguente comando:

apache2ctl -version

Vedrai la versione di Apache nel seguente output:

Server version: Apache/2.4.52 (Ubuntu)
Server built:   2022-03-25T00:35:40

Puoi anche testare l’installazione di Apache tramite il browser web utilizzando l’URL http://your-server-ip. Dovresti vedere la pagina di test di Apache sullo schermo seguente:

Una volta terminato, puoi procedere all’installazione di PHP.

Installa PHP su Ubuntu 22.04

PHP è un linguaggio di elaborazione utilizzato per servire le pagine PHP. Per impostazione predefinita, Ubuntu 22.04 fornisce l’ultima versione di PHP 8.1. Puoi installarlo con altre estensioni nel seguente output:

apt-get install php8.1 libapache2-mod-php8.1 php8.1-mysql php8.1-gd php8.1-curl php8.1-xml -y

Una volta installato PHP, puoi verificare la versione di PHP utilizzando il seguente comando:

php --version

Dovresti vedere la versione di PHP nel seguente output:

PHP 8.1.2 (cli) (built: Apr  7 2022 17:46:26) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2, Copyright (c), by Zend Technologies

Una volta terminato, puoi procedere all’installazione del server MySQL.

Installa MySQL Server su Ubuntu 22.04

Per impostazione predefinita, l’ultima versione di MySQL è inclusa nel repository predefinito di Ubuntu 22.04. Puoi installarlo utilizzando il seguente comando:

apt-get install mysql-server -y

Una volta installato il server MySQL, avvia il servizio MySQL e abilitalo per avviarsi al riavvio del sistema utilizzando il seguente comando:

systemctl start mysql  
systemctl enable mysql

Puoi controllare lo stato di MySQL utilizzando il seguente comando:

systemctl status mysql

Otterrai il seguente output:

? mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2022-04-29 07:43:21 UTC; 3s ago
    Process: 11468 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 11476 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 4630)
     Memory: 358.2M
        CPU: 991ms
     CGroup: /system.slice/mysql.service
             ??11476 /usr/sbin/mysqld

Apr 29 07:43:20 ubuntu systemd[1]: Starting MySQL Community Server...
Apr 29 07:43:21 ubuntu systemd[1]: Started MySQL Community Server.

Puoi anche controllare la versione di MySQL con il seguente comando:

mysql --version

Otterrai il seguente output:

mysql  Ver 8.0.28-0ubuntu4 for Linux on x86_64 ((Ubuntu))

Per impostazione predefinita, MySQL non è sicuro e la password di root non è impostata. Quindi dovrai proteggerlo eseguendo il seguente script:

mysql_secure_installation

Imposta una nuova password MySQL come mostrato di seguito:

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: 
Please set the password for root here.

New password: 

Re-enter new password: 
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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.

Rimuovi l’utente anonimo come mostrato di seguito:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : 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.

Disabilita il login remoto di root come mostrato di seguito:

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL 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.

Rimuovi il database di test come mostrato di seguito:

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : 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.

Ricarica i privilegi come mostrato di seguito:

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 

Verifica l'installazione di PHP

Dopo aver installato il server LAMP, dovrai controllare se Apache elabora la pagina PHP o meno.

Per controllarlo, crea una pagina PHP di esempio:

nano /var/www/html/info.php

Aggiungi il seguente codice:


Salva e chiudi il file, quindi apri il tuo browser web e accedi alla pagina PHP utilizzando l’URL http://your-server-ip/info.php. Dovresti vedere la pagina delle informazioni PHP sullo schermo seguente:

Conclusione

Congratulazioni! hai installato con successo il server LAMP su Ubuntu 22.04. Ora puoi iniziare a creare e ospitare il tuo sito web utilizzando lo stack LAMP. Sentiti libero di chiedermi se hai domande.

Share: X/Twitter LinkedIn

Ricevi i nuovi post nella tua casella di posta.

Nessuno spam. Disiscriviti in qualsiasi momento.