Come installare Bolt CMS con Nginx su Ubuntu 20.04
Su questa pagina
- Prerequisiti
- Per iniziare
- Installa il server LEMP
- Crea un database per Bolt
- Scarica Bolt CMS
- Configura Nginx per Bolt
- Access Bolt CMS
- Proteggi BoltCMS con Lets Encrypt SSL
- Conclusione
Bolt è un sistema di gestione dei contenuti gratuito, open source, leggero e semplice basato su PHP. È progettato per la facilità d'uso e ti aiuta a creare facilmente siti Web di contenuti potenti e dinamici. È costruito su microframework Silex ed è un'ottima alternativa per chi cerca un moderno sistema PHP. Viene creato utilizzando moderne librerie open source ed è più adatto per creare siti in HTML5 con markup moderno.
In questo tutorial, ti mostreremo come installare Bolt CMS con Nginx e Lets Encrypt SSL su Ubuntu 20.04.
Prerequisiti
- Un server che esegue Ubuntu 20.04.
- Un nome di dominio valido indicato con l'IP del tuo server.
- Il server è configurato con una password di root.
Iniziare
Prima di iniziare, è sempre consigliabile aggiornare il sistema con l'ultima versione dei pacchetti. Puoi aggiornarlo con il seguente comando:
apt-get update -y
Una volta aggiornati tutti i pacchetti, installa altre dipendenze eseguendo il seguente comando:
apt-get install software-properties-common gnupg2 unzip git -y
Dopo aver installato tutte le dipendenze, puoi procedere al passaggio successivo.
Installa il server LEMP
Innanzitutto, installa il server Nginx e MariaDB eseguendo il seguente comando:
apt-get install nginx mariadb-server -y
Successivamente, dovrai installare PHP versione 7.2 nel tuo server. Per impostazione predefinita, Ubuntu 20.04 viene fornito con PHP versione 7.4. Quindi dovrai aggiungere il repository Ondrej PHP nel tuo sistema.
Puoi aggiungere il repository PHP con il seguente comando:
add-apt-repository ppa:ondrej/php
Una volta aggiunto il repository, aggiorna il repository e installa PHP e altre estensioni richieste con il seguente comando:
apt-get update -y
apt-get install php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mbstring php7.2-zip php7.2-pgsql php7.2-sqlite3 php7.2-curl php7.2-gd php7.2-mysql php7.2-intl php7.2-json php7.2-opcache php7.2-xml -y
Once all the packages are installed, you can proceed to the next step.
Crea un database per Bolt
Successivamente, dovrai creare un database e un utente per Bolt. Innanzitutto, accedi a MariaDB con il seguente comando:
mysql
Una volta effettuato l'accesso, creare un database e un utente con il seguente comando:
MariaDB [(none)]> CREATE DATABASE boltdb;
MariaDB [(none)]> CREATE USER 'bolt'@'localhost' IDENTIFIED BY 'password';
Quindi, concedi tutti i privilegi al database Bolt con il seguente comando:
MariaDB [(none)]> GRANT ALL ON boltdb.* TO 'bolt'@'localhost';
Successivamente, svuota i privilegi ed esci dalla shell MariaDB con il seguente comando:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Una volta terminato, puoi procedere al passaggio successivo.
Scarica BoltCMS
Innanzitutto, dovrai scaricare l'ultima versione di Bolt CMS dal repository Git. Puoi scaricarlo nella directory principale di Nginx eseguendo il seguente comando:
cd /var/www/html
git clone https://github.com/bolt/bolt.git
Una volta scaricato Bolt, cambia la directory in bolt e copia il file di configurazione di esempio:
cd bolt
cp app/config/config.yml.dist app/config/config.yml
Successivamente, modifica il file config.yml e definisci le impostazioni del database:
nano app/config/config.yml
Rimuovi la riga predefinita del database sqlite e aggiungi le seguenti righe:
database: driver: mysql username: bolt password: password databasename: boltdb host: localhost prefix: prefix_
Salva e chiudi il file quando hai finito.
Successivamente, dovrai installare Composer nel tuo sistema. Composer è un gestore delle dipendenze per PHP. Puoi installarlo con il seguente comando:
wget -O composer-setup.php https://getcomposer.org/installer
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Una volta installato Composer, dovresti ottenere il seguente output:
All settings correct for using Composer Downloading... Composer (version 2.0.2) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer
Successivamente, installa le dipendenze PHP richieste per Bolt CMS con il seguente comando:
composer install
Una volta installate tutte le dipendenze, modificare la proprietà e le autorizzazioni della directory in grassetto:
chown -R www-data:www-data /var/www/html/bolt
chmod -R 755 /var/www/html/bolt
Una volta terminato, puoi procedere al passaggio successivo.
Configura Nginx per Bolt
Successivamente, dovrai creare un file di configurazione dell'host virtuale Nginx per Bolt CMS. Puoi crearlo con il seguente comando:
nano /etc/nginx/sites-available/bolt.conf
Aggiungi le seguenti righe:
server { listen 80; root /var/www/html/bolt; index index.php index.html index.htm; server_name bolt.example.com; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ [^/]\.php(/|$) { try_files /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_index index.php; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location = /bolt { try_files $uri /index.php?$query_string; } location ^~ /bolt/ { try_files $uri /index.php?$query_string; } }
Salva e chiudi il file quando hai finito, quindi abilita il file host virtuale Nginx usando il seguente comando:
ln -s /etc/nginx/sites-available/bolt.conf /etc/nginx/sites-enabled/bolt.conf
Successivamente, verifica Nginx per qualsiasi errore di configurazione con il seguente comando:
nginx -t
Dovresti vedere il seguente output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Infine, riavvia il servizio Nginx per applicare le modifiche:
systemctl restart nginx
A questo punto, Nginx è configurato per servire Bolt CMS. Ora puoi procedere al passaggio successivo.
Accesso Bolt CMS
Ora apri il tuo browser web e digita l'URL http://bolt.example.com. Verrai reindirizzato alla seguente pagina:
Fornisci il nome utente, la password, l'e-mail desiderati e fai clic sul pulsante Crea il primo utente. Dovresti vedere la dashboard di Bolt CMS nella pagina seguente:
Ora, fai clic sul pulsante Visualizza sito. Dovresti vedere la semplice pagina del sito di Bolt CMS nella pagina seguente:
Proteggi BoltCMS con Lets Encrypt SSL
È sempre una buona idea proteggere il tuo sito web con Lets Encrypt SSL. Innanzitutto, installa il client Certbot Lets Encrypt nel tuo server con il seguente comando:
apt-get install python3-certbot-nginx -y
Una volta installato, proteggi il tuo sito web con Lets Encrypt SSL eseguendo il seguente comando:
certbot --nginx -d bolt.example.com
Ti verrà chiesto di fornire un indirizzo email valido e di accettare i termini di servizio come mostrato di seguito:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator nginx, Installer nginx 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 Obtaining a new certificate Performing the following challenges: http-01 challenge for bolt.example.com Waiting for verification... Cleaning up challenges Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/bolt.conf
Successivamente, scegli se reindirizzare o meno il traffico HTTP su HTTPS come mostrato di seguito:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 completare l'installazione. Dovresti vedere il seguente output:
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/bolt.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://bolt.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=bolt.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/bolt.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/bolt.example.com/privkey.pem Your cert will expire on 2020-10-30. 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" - 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 - We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.
Ora, il tuo sito Web BoltCMS è protetto con Lets Encrypt SSL. Puoi accedervi in modo sicuro utilizzando l'URL https://bolt.example.com
Conclusione
Congratulazioni! hai installato con successo Bolt CMS con Nginx e Lets Encrypt SSL sul server Ubuntu 20.04. Ora puoi creare facilmente il tuo sito Web utilizzando la dashboard di Bolt. Non esitate a chiedermi se avete domande.