Cómo instalar Flatpress CMS con Let’s Encrypt SSL en Ubuntu 22.04

FlatPress es un sistema de gestión de contenidos gratuito y de código abierto y el más rápido. Está escrito en lenguaje PHP y es una gran herramienta para cualquiera que no tenga acceso a bases de datos. Es un motor de blogs ligero, fácil de configurar y estupendo en la categoría social y de comunicaciones. Admite varios idiomas, plugins, temas, widgets y mucho más.

En este tutorial Voy a explicar cómo instalar FlatPress en un servidor Ubuntu 22.04.

Requisitos

  • Un servidor con Ubuntu 22.04.
  • Un usuario no root con privilegios sudo.

Instalar Apache y PHP

Por defecto, PHP 8.1 es la versión de PHP por defecto en Ubuntu 22.04. Pero FlatPress sólo es compatible con la versión PHP 8.0. Por lo tanto, tendrás que añadir el repositorio PHP a tu sistema. Puedes añadirlo con el siguiente comando:

apt install software-properties-common -y
add-apt-repository ppa:ondrej/php

Una vez añadido el repositorio, instala Apache, PHP y todas las extensiones PHP necesarias ejecutando el siguiente comando:

apt-get install apache2 php8.0 php8.0-mysql php8.0-curl php8.0-cgi libapache2-mod-php8.0 php8.0-mcrypt php8.0-xmlrpc php8.0-gd php8.0-mbstring php8.0 php8.0-common php8.0-xmlrpc php8.0-soap php8.0-xml php8.0-intl php8.0-cli php8.0-ldap php8.0-zip php8.0-readline php8.0-imap php8.0-tidy php8.0-sql php8.0-intl wget unzip -y

Tras instalar todos los paquetes, inicia el servicio Apache y habilítalo para que se inicie al arrancar el sistema con el siguiente comando:

systemctl start apache2
systemctl enable apache2

Una vez que hayas terminado, puedes pasar al siguiente paso.

Instalar FlatPress

En primer lugar, visita el repositorio Git de FlatPress y descarga la última versión con el siguiente comando:

wget https://github.com/flatpressblog/flatpress/archive/1.2.1.zip

A continuación, descomprime el archivo descargado con el siguiente comando:

unzip 1.2.1.zip

A continuación, copia el directorio extraído al directorio raíz de Apache y dale los permisos adecuados con el siguiente comando:

cp -r flatpress-1.2.1 /var/www/html/flatpress
chown -R www-data.www-data /var/www/html/flatpress
chmod -R 775 /var/www/html/flatpress

Configurar Apache para FlatPress

A continuación, tendrás que crear un archivo de host virtual de Apache para Flatpress. Puedes crearlo con el siguiente comando

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

Añade las siguientes líneas:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/flatpress
     ServerName flatpress.example.com

     <Directory /var/www/html/flatpress/>
          AllowOverride All
          Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/flatpress_error.log
     CustomLog ${APACHE_LOG_DIR}/flatpress_access.log combined

</VirtualHost>

Guarda y cierra el archivo. A continuación, habilita el host virtual con el siguiente comando:

a2ensite flatpress

A continuación, habilita el módulo de reescritura de Apache y recarga el servicio Apache con el siguiente comando:

a2enmod rewrite
systemctl restart apache2

También puedes comprobar el estado de Apache con el siguiente comando:

systemctl status apache2

Deberías ver la siguiente salida:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2022-11-20 11:37:30 UTC; 6s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 100768 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 100772 (apache2)
      Tasks: 6 (limit: 2242)
     Memory: 14.3M
        CPU: 85ms
     CGroup: /system.slice/apache2.service
             ??100772 /usr/sbin/apache2 -k start
             ??100773 /usr/sbin/apache2 -k start
             ??100774 /usr/sbin/apache2 -k start
             ??100775 /usr/sbin/apache2 -k start
             ??100776 /usr/sbin/apache2 -k start
             ??100777 /usr/sbin/apache2 -k start

Nov 20 11:37:30 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...

Una vez que hayas terminado, puedes pasar al siguiente paso.

Asegura FlatPress con Let’s Encrypt SSL

Es una buena idea asegurar tu sitio FlatPress con un certificado SSL de Let’s Encrypt. Para ello, necesitarás instalar el cliente Certbot en tu sistema. Certbot es un paquete cliente que te ayuda a descargar y gestionar certificados SSL en tu sitio web.

Puedes instalar el Certbot con el siguiente comando:

apt-get install certbot python3-certbot-apache -y

Una vez que el cliente Certbot se haya instalado correctamente, ejecuta el siguiente comando para instalar el SSL de Let’s Encrypt para tu sitio web:

certbot --apache -d flatpress.example.com

Se te pedirá que proporciones tu correo electrónico válido y que aceptes las condiciones del servicio, como se muestra a continuación:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
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 flatpress.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/flatpress-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/flatpress-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/flatpress-le-ssl.conf

A continuación, selecciona si deseas redirigir el tráfico HTTP a HTTPS o configurar Nginx para que redirija todo el tráfico a un acceso seguro HTTPS, como se muestra en la siguiente salida:

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

Escribe 2 y pulsa Intro para iniciar el proceso. Una vez completada la instalación, deberías obtener la siguiente salida:

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

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

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

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/flatpress.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/flatpress.example.com/privkey.pem
   Your cert will expire on 2023-02-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

En este punto, tu sitio FlatPress está protegido con Let’s Encrypt SSL. Ahora puedes acceder a tu sitio de forma segura utilizando el protocolo HTTPS.

Acceder a FlatPress CMS

Ahora, abre tu navegador web y escribe la URL https://flatpress.example.com. Serás redirigido a la página de instalación de FlatPress:’

Instalador del CMS FlatPress

Ahora, haz clic en el botón Siguiente. Deberías ver la página de creación de usuarios Admin:

Crear un usuario

Aquí, proporciona tu nombre de usuario admin, contraseña, correo electrónico y haz clic en el botón Siguiente. Deberías ver la siguiente página:

Instalación de FlatPress finalizada

Haz clic en el botón Iniciar sesión ahora. Deberías ver la siguiente página:

Inicio de sesión en FlatPress

Proporciona tu nombre de usuario admin, contraseña y haz clic en el botón Iniciar sesión. Deberías ver la siguiente página:

FlatPress Admin

Conclusión

Este tutorial ha explicado cómo instalar FlatPress con Apache y Let’s Encrypt SSL en Ubuntu 22.04. Ahora puedes crear un sitio web y un blog sencillos y rápidos utilizando el CMS FlatPress. No dudes en preguntarme si tienes alguna duda.

Scroll al inicio