Installazione CMS · 8 min read · Sep 26, 2025

Come installare CraftCMS con Apache e Let's Encrypt SSL su Ubuntu 22.04 LTS

Craft è un sistema di gestione dei contenuti open-source, flessibile e ricco di funzionalità per sviluppatori e autori di contenuti. Offre tutte le funzionalità di personalizzazione necessarie per costruire un sito web potente. Ti consente di gestire il contenuto di vari siti da un’unica dashboard. È una soluzione alternativa a WordPress e Drupal per costruire esperienze digitali su misura. Ha centinaia di plugin gratuiti e a pagamento che ti permettono di aggiungere funzionalità.

Questo post spiegherà come installare Craft CMS con Apache e Let’s Encrypt SSL su Ubuntu 22.04.

Prerequisiti

  • Un server che esegue Ubuntu 22.04.
  • Un nome di dominio valido puntato all’IP del tuo server.
  • Una password di root configurata sul server.

Installa il server LAMP

Craft CMS gira sul server web, è scritto in PHP e utilizza MariaDB come backend del database. Quindi dovrai installare tutti questi pacchetti sul tuo server.

Puoi eseguire il seguente comando per installare tutti questi pacchetti:

apt-get install apache2 mariadb-server php php-cli libapache2-mod-php php-common php-json php-curl php-gd php-imagick php-json php-mbstring php-mysql php-pgsql php-zip php-intl php-xml -y

Dopo aver installato tutti i pacchetti, modifica il file di configurazione PHP e cambia le impostazioni predefinite:

nano /etc/php/8.1/php.ini

Cambia le seguenti impostazioni:

memory_limit = 512M
post_max_size = 32M
upload_max_filesize = 32M
max_execution_time = 360

Salva e chiudi il file, quindi riavvia il servizio Apache per applicare le modifiche:

systemctl restart apache2

Crea un database per CraftCMS

Successivamente, dovrai creare un database e un utente per Craft CMS. Prima, accedi alla shell di MariaDB con il seguente comando:

mysql

Una volta effettuato l’accesso, crea un database e un utente con il seguente comando:

MariaDB [(none)]> CREATE DATABASE craftcms;  
MariaDB [(none)]> GRANT ALL ON craftcms.* TO 'craftuser' IDENTIFIED BY 'password';

Successivamente, svuota i privilegi e esci dalla shell di MariaDB con il seguente comando:

MariaDB [(none)]> FLUSH PRIVILEGES;  
MariaDB [(none)]> EXIT;

A questo punto, il database MariaDB è stato creato per Craft CMS. Puoi ora procedere al passaggio successivo.

Installa Craft CMS utilizzando Composer

Successivamente, dovrai installare Composer per scaricare l’ultima versione di Craft CMS. Puoi installarlo utilizzando il seguente comando:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

Una volta installato Composer, naviga nella directory radice web di Apache e crea un progetto Craft CMS utilizzando il seguente comando:

cd /var/www/html  
composer create-project craftcms/craft craftcms

Ti verrà chiesto di fornire le impostazioni del tuo database, nome utente admin, password, URL del sito come mostrato di seguito:

Which database driver are you using? (mysql or pgsql) [mysql] 
Database server name or IP address: [127.0.0.1] 
Database port: [3306] 
Database username: [root] craftuser
Database password: 
Database name: craft
Database table prefix: 
Testing database credentials ... success!
Saving database credentials to your .env file ... done

Install Craft now? (yes|no) [yes]:yes

Username: [admin] admin
Email: [email protected]
Password: 
Confirm: 
Site name: CraftCMS Site
Site URL: http://craftcms.example.com
Site language: [en-US] 

    > add foreign key fk_rlbmgnhpxsljkaunjwnsezfrnrkhwzpthfsq: {{%widgets}} (userId) references {{%users}} (id) ... done (time: 0.035s)
    > populating the info table ... done
    > saving default site data ... done
    > saving the first user ... done
*** installed Craft successfully (time: 5.449s)

Successivamente, imposta i permessi e la proprietà corretti nella directory di Craft CMS:

chown -R www-data:www-data /var/www/html/craftcms/  
chmod -R 755 /var/www/html/craftcms/

Una volta terminato, puoi procedere al passaggio successivo.

Configura Apache per Craft CMS

Successivamente, dovrai creare un file di configurazione del virtual host Apache per Craft CMS. Puoi crearlo con il seguente comando:

nano /etc/apache2/sites-available/craftcms.conf

Aggiungi le seguenti righe:


     ServerAdmin [email protected]
     DocumentRoot /var/www/html/craftcms/web
     ServerName craftcms.example.com


     
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
    
     
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^(.*) index.php [PT,L]
    

Salva e chiudi il file, quindi attiva il virtual host Apache e il modulo di riscrittura utilizzando il seguente comando:

a2ensite craftcms.conf  
a2enmod rewrite

Successivamente, riavvia il servizio Apache per applicare le modifiche:

systemctl restart apache2

Puoi anche controllare lo stato di Apache con il seguente comando:

systemctl status apache2

Otterrai il 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-06-17 15:48:11 UTC; 31min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 37935 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
    Process: 40916 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
   Main PID: 37939 (apache2)
      Tasks: 6 (limit: 2292)
     Memory: 53.0M
        CPU: 28.718s
     CGroup: /system.slice/apache2.service
             ??37939 /usr/sbin/apache2 -k start
             ??40920 /usr/sbin/apache2 -k start
             ??40921 /usr/sbin/apache2 -k start
             ??40922 /usr/sbin/apache2 -k start
             ??40923 /usr/sbin/apache2 -k start
             ??40924 /usr/sbin/apache2 -k start

Jun 17 15:48:11 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...

Una volta configurato il tuo server web Apache, puoi procedere al passaggio successivo.

Accedi all’interfaccia web di Craft CMS

Ora, apri il tuo browser web e digita l’URL http://craftcms.example.com per accedere all’interfaccia web di Craft CMS. Dovresti vedere la seguente pagina:

Clicca su vai al tuo pannello di controllo. Sarai reindirizzato alla pagina di accesso di Craft CMS:

Fornisci il tuo nome utente admin, password e clicca sul pulsante login. Dovresti vedere il dashboard di Craft CMS nella seguente pagina:

Sicurezza di Craft CMS con Let’s Encrypt SSL

Successivamente, è una buona idea proteggere il tuo sito web con Let’s Encrypt SSL. Prima, installa il pacchetto client Certbot con il seguente comando:

apt-get install python3-certbot-apache -y

Dopo l’installazione riuscita, esegui il seguente comando per proteggere il tuo sito web con Let’s Encrypt SSL:

certbot --apache -d craftcms.example.com

Ti verrà chiesto di fornire la tua email e accettare i termini di servizio come mostrato di seguito:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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: Y
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for craftcms.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/craftcms-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/craftcms-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/craftcms-le-ssl.conf

Successivamente, seleziona se reindirizzare o meno il traffico HTTP a HTTPS come mostrato di seguito:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Digita 2 e premi Invio per installare il Let’s Encrypt SSL per il tuo sito web:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/craftcms.conf to ssl vhost in /etc/apache2/sites-available/craftcms-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://craftcms.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=craftcms.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/craftcms.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/craftcms.example.com/privkey.pem
   Your cert will expire on 2022-09-17. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - 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

Conclusione

Congratulazioni! hai installato con successo Craft CMS con Apache e Let’s Encrypt SSL su Ubuntu 22.04. Puoi ora esplorare le funzionalità di CraftCMS e iniziare a creare un sito web potente utilizzando Craft CMS. 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.