GNU/Linux >> Tutoriales Linux >  >> Ubuntu

Cómo instalar Grav CMS con Nginx en Ubuntu 20.04

Grav es un CMS gratuito, de código abierto y de archivo plano que no requiere ninguna base de datos. Está basado en PHP y ofrece varias funciones que pueden no estar disponibles para otros CMS como WordPress, Joomla, etc. Es simple, fácil de usar y viene con algunas de las tecnologías clave, incluidas Twig Templating, Markdown, YAML, Parsedown, Doctrine Cache, Gregwar Image Library y Symfony Console.

En este tutorial, le mostraré cómo instalar Grav CMS con Nginx y Let's Encrypt SSL en el servidor Ubuntu 20.04.

Requisitos

  • Un servidor con Ubuntu 20.04.
  • Un nombre de dominio válido apuntado con la IP de su servidor.
  • Se configura una contraseña raíz en el servidor.

Cómo empezar

Primero, actualice los paquetes del sistema a la versión actualizada ejecutando el siguiente comando:

apt-get update -y

Una vez que todos los paquetes estén actualizados, puede continuar con el siguiente paso.

Instalar Nginx y PHP

Primero, deberá instalar el servidor web Nginx, PHP y otras extensiones de PHP en su sistema. Puede instalarlos todos con el siguiente 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 vez que todos los paquetes estén instalados, verifique la versión de PHP usando el siguiente comando:

php --version

Deberías obtener el siguiente resultado:

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

A continuación, edite el archivo php.ini y realice algunos cambios:

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

Cambie las siguientes líneas:

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

Guarde y cierre el archivo y luego reinicie el servicio PHP-FPM para aplicar los cambios:

systemctl restart php7.4-fpm

Una vez que haya terminado, puede continuar con el siguiente paso.

Instalar Grav CMS

A continuación, deberá descargar Grav CMS en el directorio raíz web de Nginx. Puede descargarlo desde la página de descarga de Grav usando el siguiente comando:

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

Una vez completada la descarga, descomprima el archivo descargado con el siguiente comando:

unzip 1.7.17

A continuación, cambie el nombre del directorio extraído a grav con el siguiente comando:

mv grav-admin grav

A continuación, establezca la propiedad adecuada en el directorio grav:

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

Una vez que haya terminado, puede continuar con el siguiente paso.

Configurar Nginx para Grav CMS

A continuación, deberá crear un archivo de configuración de host virtual Nginx para alojar Grav CMS. Puedes crearlo con el siguiente comando:

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

Agregue las siguientes líneas:

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;
 }

}

Guarde y cierre el archivo cuando haya terminado, luego verifique el Nginx para cualquier error de sintaxis:

nginx -t

Deberías obtener el siguiente resultado:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Finalmente, reinicie el servicio Nginx para aplicar los cambios:

systemctl restart nginx

También puede verificar el estado de Nginx con el siguiente comando:

systemctl status nginx

Debería ver el siguiente resultado:

? 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.

Una vez que todo esté bien, puede continuar con el siguiente paso.

Acceder a Grav CMS

Ahora puede acceder a la interfaz de usuario web de Grav CMS utilizando la URL http://grav.example.com . Debería ver la siguiente pantalla:

Establezca su nombre de usuario y contraseña de administrador y haga clic en Crear usuario botón. Será redirigido al panel de Grav CMS:

Página de configuración

Página de cuentas

Página de complementos

Página de herramientas

Secure Grav CMS con Let's Encrypt SSL

A continuación, deberá instalar el paquete de cliente de Certbot para instalar y administrar Let's Encrypt SSL.

Primero, instale Certbot con el siguiente comando:

apt-get install python3-certbot-nginx -y

Una vez finalizada la instalación, ejecute el siguiente comando para instalar Let's Encrypt SSL en su sitio web:

certbot --nginx -d grav.example.com

Se le pedirá que proporcione una dirección de correo electrónico válida y acepte el término de servicio como se muestra a continuación:

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

A continuación, elija si desea o no redirigir el tráfico HTTP a HTTPS como se muestra a continuación:

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

Escriba 2 y presione Entrar para finalizar la instalación. Debería ver el siguiente resultado:

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.

Ahora puede acceder a Grav CMS de forma segura utilizando el protocolo HTTPS.

Conclusión

¡Felicidades! ha instalado con éxito Grav CMS con Nginx y Let's Encrypt SSL en el servidor Ubuntu 20.04. Ahora puede crear su sitio web fácilmente utilizando Grav CMS.


Ubuntu
  1. Cómo instalar MediaWiki con Nginx en Ubuntu 16.04

  2. Cómo instalar Grav CMS con Nginx en Ubuntu 16.04

  3. Cómo instalar Grav CMS en Ubuntu 15.04

  4. Cómo instalar Grav CMS en Ubuntu 18.04

  5. Cómo instalar PHP 7.4 con Nginx en Ubuntu 20.04

Cómo instalar OSClass con Nginx en Ubuntu 20.04

Cómo instalar Bolt CMS con Nginx en Ubuntu 20.04

Cómo instalar Craft CMS con Nginx en Ubuntu 20.04

Cómo instalar Grav CMS con Nginx en Debian 9

Cómo instalar WonderCMS en Ubuntu 20.04 (con Nginx)

Cómo instalar Laravel PHP Framework con Nginx en Ubuntu 20.04