Come installare Drupal con Apache e crittografare SSL su Debian 11
Questo tutorial esiste per queste versioni del sistema operativo
- Debian 11 (Bullseye)
- Debian 9 (Stretch)
Su questa pagina
- Prerequisiti
- Installa lo stack LAMP
- Crea un database Drupal
- Scarica Drupal
- Crea un host virtuale Apache per Drupal
- Accedi al sito Web Drupal
- Abilita Let's Encrypt SSL Support sul sito Web Drupal
- Conclusione
Drupal è un sistema di gestione dei contenuti gratuito e open source basato sullo stack LAMP. Drupal ha ottime funzionalità standard che ti consentono di creare potenti siti Web e blog. Viene fornito con molti temi, plug-in e widget che ti aiutano a creare un sito Web senza alcuna conoscenza di programmazione. Fornisce molte funzionalità come supporto multi-sito, supporto multilingue, sistema di commenti, feed RSS, registrazione utente e altro.
In questo post, ti mostreremo come installare Drupal CMS con Apache e Lets Encrypt SSL su Debian 11.
Prerequisiti
- Un server che esegue Debian 11.
- Un nome di dominio valido indicato con l'IP del tuo server.
- Sul server è configurata una password di root.
Installa LAMP Stack
Drupal è basato sullo stack LAMP. Quindi lo stack LAMP deve essere installato nel tuo server. Se non è installato, puoi installarlo eseguendo il seguente comando:
apt-get install apache2 mariadb-server mariadb-client php libapache2-mod-php php-cli php-mysql php-zip php-gd php-fpm php-json php-common php-intl php-mbstring php-curl php-xml php-pear php-tidy php-soap php-bcmath php-xmlrpc -y
Una volta installato lo stack LAMP, modifica il file php.ini e modifica alcune impostazioni predefinite:
nano /etc/php/7.4/apache2/php.ini
Modifica le seguenti righe:
memory_limit = 256M upload_max_filesize = 32M max_execution_time = 300 date.timezone = Asia/Kolkata
Salva e chiudi il file quando hai finito.
Crea un database Drupal
Drupal utilizza un MariaDB come backend del database. Quindi dovrai creare un database e un utente per Drupal.
Innanzitutto, accedi a MariaDB con il seguente comando:
mysql
Una volta effettuato l'accesso, creare un database e un utente utilizzando il seguente comando:
MariaDB [(none)]> CREATE DATABASE drupaldb;
MariaDB [(none)]> CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY "securepassword";
Successivamente, concedi tutti i privilegi al database Drupal utilizzando il seguente comando:
MariaDB [(none)]> GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY "securepassword";
Successivamente, scarica i privilegi ed esci da MariaDB con il seguente comando:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Scarica drupal
Innanzitutto, vai sul sito Web di Drupal, scegli l'ultima versione di Drupal e scaricala con il seguente comando:
wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz
Una volta scaricato Drupal, estrai il file scaricato con il seguente comando:
tar -xvf drupal.tar.gz
Successivamente, sposta la directory estratta nella directory principale predefinita di Apache:
mv drupal-* /var/www/html/drupal
Successivamente, modifica la proprietà e l'autorizzazione della directory Drupal utilizzando il seguente comando:
chown -R www-data:www-data /var/www/html/drupal/
chmod -R 755 /var/www/html/drupal/
Crea un host virtuale Apache per Drupal
Successivamente, dovrai creare un file di configurazione dell'host virtuale Apache per ospitare Drupal. Puoi crearlo usando il seguente comando:
nano /etc/apache2/sites-available/drupal.conf
Aggiungi le seguenti righe:
<VirtualHost *:80> ServerAdmin DocumentRoot /var/www/html/drupal/ ServerName drupal.example.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined <Directory /var/www/html/drupal/> Options FollowSymlinks AllowOverride All Require all granted </Directory> <Directory /var/www/html/> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] </Directory> </VirtualHost>
Salvare e chiudere il file quindi abilitare l'host virtuale Drupal e il modulo di riscrittura Apache con il seguente comando:
a2ensite drupal.conf
a2enmod rewrite
Successivamente, riavvia il servizio Apache per applicare le modifiche:
systemctl restart apache2
Per verificare lo stato di Apache, eseguire il seguente comando:
systemctl status apache2
Dovresti ottenere il seguente output:
? apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-09-18 14:59:40 UTC; 5s ago Docs: https://httpd.apache.org/docs/2.4/ Process: 19698 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 19703 (apache2) Tasks: 6 (limit: 2341) Memory: 15.3M CPU: 78ms CGroup: /system.slice/apache2.service ??19703 /usr/sbin/apache2 -k start ??19704 /usr/sbin/apache2 -k start ??19705 /usr/sbin/apache2 -k start ??19706 /usr/sbin/apache2 -k start ??19707 /usr/sbin/apache2 -k start ??19708 /usr/sbin/apache2 -k start
A questo punto, il server web Apache è configurato per servire Drupal. Ora puoi procedere al passaggio successivo.
Accedi al sito Web Drupal
Ora apri il tuo browser web e accedi a Drupal utilizzando l'URL http://drupal.example.com. Verrai reindirizzato alla seguente pagina:
Scegli la lingua inglese e fai clic sul pulsante Salva e continua, dovresti vedere la seguente immagine:
Selezionare un profilo di installazione e fare clic sul pulsante Salva e continua. Dovresti vedere la seguente pagina:
Nella pagina Configurazione database, fornisci tutti i dettagli del database richiesti come nome del database, nome utente e password del database, host del database, quindi fai clic sul pulsante Salva e continua, dovresti vedere la seguente immagine:
Nella pagina Drupal Site Configuration, fornisci il nome del tuo sito, il nome utente e la password dell'amministratore, quindi fai clic sul pulsante Salva e continua per avviare l'installazione di Drupal. Una volta installato Drupal, dovresti vedere la dashboard di Drupal nella seguente immagine:
Abilita consente di crittografare il supporto SSL sul sito Web Drupal
È sempre una buona idea proteggere il tuo sito web con Lets Encrypt SSL. Innanzitutto, dovrai installare il client Certbot per installare e gestire SSL. Per impostazione predefinita, il pacchetto Certbot è incluso nel repository predefinito di Debian 11, quindi è possibile installarlo con il seguente comando:
apt-get install python3-certbot-apache -y
Una volta installato Certbot, esegui il seguente comando per proteggere il tuo sito web con Lets Encrypt SSL:
certbot --apache -d drupal.example.com
Ti verrà chiesto di fornire la tua email e di 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): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 drupal.example.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/drupal-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/drupal-le-ssl.conf Enabling available site: /etc/apache2/sites-available/drupal-le-ssl.conf
Successivamente, seleziona se reindirizzare o meno il traffico HTTP su 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 Lets Encrypt SSL per il tuo sito web:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/drupal.conf to ssl vhost in /etc/apache2/sites-available/drupal-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://drupal.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=drupal.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/drupal.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/drupal.example.com/privkey.pem Your cert will expire on 2021-04-20. 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
Questo è tutto per ora. Hai installato correttamente Drupal con Lets Encrypt SSL su Debian 11. Ora puoi iniziare a creare il tuo blog o sito web senza alcuna conoscenza di programmazione. Non esitate a chiedermi se avete domande.