GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare Grav CMS con Nginx su Ubuntu 20.04

Grav è un CMS gratuito, open source e flat-file che non richiede alcun database. Si basa su PHP e offre diverse funzionalità che potrebbero non essere disponibili per altri CMS come WordPress, Joomla, ecc. È semplice, facile da usare e include alcune delle tecnologie chiave tra cui Twig Templating, Markdown, YAML, Parsedown, Doctrine Cache, Gregwar Image Library e Symfony Console.

In questo tutorial, ti mostrerò come installare Grav CMS con Nginx e Let's Encrypt SSL sul server Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Un nome di dominio valido puntato all'IP del tuo server.
  • Sul server è configurata una password di root.

Per iniziare

Innanzitutto, aggiorna i pacchetti di sistema alla versione aggiornata eseguendo il comando seguente:

apt-get update -y

Una volta aggiornati tutti i pacchetti, puoi procedere al passaggio successivo.

Installa Nginx e PHP

Innanzitutto, dovrai installare il server web Nginx, PHP e altre estensioni PHP sul tuo sistema. Puoi installarli tutti con il seguente comando:

apt-get install nginx php php-cli php-fpm php-common php-curl php-gd php-json php-mbstring php-xml php-zip php-opcache php-apcu unzip -y

Una volta installati tutti i pacchetti, verifica la versione PHP utilizzando il seguente comando:

php --version

Dovresti ottenere il seguente output:

PHP 7.4.3 (cli) (built: Jul  5 2021 15:13:35) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies

Quindi, modifica il file php.ini e apporta alcune modifiche:

nano /etc/php/7.4/fpm/php.ini

Modifica le seguenti righe:

memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
max_input_vars = 1500
date.timezone = America/Chicago

Salva e chiudi il file, quindi riavvia il servizio PHP-FPM per applicare le modifiche:

systemctl restart php7.4-fpm

Una volta terminato, puoi procedere al passaggio successivo.

Installa Grav CMS

Successivamente, dovrai scaricare Grav CMS nella directory principale web di Nginx. Puoi scaricarlo dalla pagina di download di Grav usando il seguente comando:

cd /var/www/html
wget https://getgrav.org/download/core/grav-admin/1.7.17

Una volta completato il download, decomprimere il file scaricato con il seguente comando:

unzip 1.7.17

Quindi, rinomina la directory estratta in grav con il seguente comando:

mv grav-admin grav

Quindi, imposta la proprietà corretta sulla directory grav:

chown -R www-data:www-data /var/www/html/grav

Una volta terminato, puoi procedere al passaggio successivo.

Configura Nginx per Grav CMS

Successivamente, dovrai creare un file di configurazione dell'host virtuale Nginx per ospitare Grav CMS. Puoi crearlo con il seguente comando:

nano /etc/nginx/conf.d/grav.conf

Aggiungi le seguenti righe:

server {

listen 80;

server_name grav.example.com;
root /var/www/html/grav;

index index.html index.php;

location / {
   try_files $uri $uri/ /index.php?$query_string;
 }

   location ~* /(\.git|cache|bin|logs|backup|tests)/.*$ { return 403; }
   location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
   location ~* /user/.*\.(txt|md|yaml|yml|php|pl|py|cgi|twig|sh|bat)$ { return 403; }
   location ~ /(LICENSE\.txt|composer\.lock|composer\.json|nginx\.conf|web\.config|htaccess\.txt|\.htaccess) { return 403; }

location ~ \.php$ {
   fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
   fastcgi_index index.php;
   include fastcgi_params;
   fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
 }

}

Salva e chiudi il file al termine, quindi verifica Nginx per eventuali errori di sintassi:

nginx -t

Dovresti ottenere 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

Puoi anche verificare lo stato di Nginx con il seguente comando:

systemctl status nginx

Dovresti vedere il seguente output:

? nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-07-09 06:45:28 UTC; 3s ago
       Docs: man:nginx(8)
    Process: 33099 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 33110 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 33111 (nginx)
      Tasks: 2 (limit: 2353)
     Memory: 2.6M
     CGroup: /system.slice/nginx.service
             ??33111 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??33112 nginx: worker process

Jul 09 06:45:28 node1 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 09 06:45:28 node1 systemd[1]: Started A high performance web server and a reverse proxy server.

Quando tutto è a posto, puoi procedere al passaggio successivo.

Accedi a Grav CMS

Ora puoi accedere all'interfaccia utente web di Grav CMS utilizzando l'URL http://grav.example.com . Dovresti vedere la seguente schermata:

Imposta il nome utente e la password dell'amministratore e fai clic su Crea utente pulsante. Verrai reindirizzato alla dashboard di Grav CMS:

Pagina di configurazione

Pagina degli account

Pagina dei plug-in

Pagina degli strumenti

Secure Grav CMS con Let's Encrypt SSL

Successivamente, dovrai installare il pacchetto client Certbot per installare e gestire Let's Encrypt SSL.

Innanzitutto, installa Certbot con il seguente comando:

apt-get install python3-certbot-nginx -y

Al termine dell'installazione, esegui il seguente comando per installare Let's Encrypt SSL sul tuo sito Web:

certbot --nginx -d grav.example.com

Ti verrà chiesto di fornire un indirizzo email valido e di accettare i termini del 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): [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
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for grav.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/grav.conf

Quindi, 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/conf.d/grav.conf

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/grav.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/grav.example.com/privkey.pem
   Your cert will expire on 2021-12-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 puoi accedere a Grav CMS in modo sicuro utilizzando il protocollo HTTPS.

Conclusione

Congratulazioni! hai installato con successo Grav CMS con Nginx e Let's Encrypt SSL sul server Ubuntu 20.04. Ora puoi creare facilmente il tuo sito web utilizzando il CMS Grav.


Ubuntu
  1. Come installare MediaWiki con Nginx su Ubuntu 16.04

  2. Come installare Grav CMS con Nginx su Ubuntu 16.04

  3. Come installare Grav CMS su Ubuntu 15.04

  4. Come installare Grav CMS su Ubuntu 18.04

  5. Come installare PHP 7.4 con Nginx su Ubuntu 20.04

Come installare OSClass con Nginx su Ubuntu 20.04

Come installare Bolt CMS con Nginx su Ubuntu 20.04

Come installare Craft CMS con Nginx su Ubuntu 20.04

Come installare Grav CMS con Nginx su Debian 9

Come installare WonderCMS su Ubuntu 20.04 (con Nginx)

Come installare Laravel PHP Framework con Nginx su Ubuntu 20.04