Cómo instalar la red social Elgg en Ubuntu 22.04

Elgg es un framework web y CMS gratuito, de código abierto y altamente personalizable para construir un entorno social online. Está escrito en PHP y utiliza MySQL como base de datos. Ofrece una interfaz web sencilla, fácil de usar y personalizable que ayuda a los usuarios principiantes a crear y gestionar contenidos a través de un navegador web. Elgg permite a escuelas, institutos y universidades crear su entorno social en el campus. Es uno de los motores de redes sociales más populares que ofrece un marco robusto sobre el que puedes construir todo tipo de entornos sociales.

Este post te mostrará cómo instalar Elgg con Nginx y Let’s Encrypt SSL en Ubuntu 22.04.

Requisitos previos

  • Un servidor con Ubuntu 22.04.
  • Un nombre de dominio válido apuntado con la IP de tu servidor.
  • Una contraseña de root configurada en el servidor.

Cómo empezar

Antes de empezar, es una buena idea actualizar los paquetes del sistema a la versión actualizada. Puedes actualizar todos los paquetes ejecutando el siguiente comando:

apt-get update -y

Tras actualizar todos los paquetes, puedes pasar al siguiente paso.

Instalar Nginx, PHP y MariaDB

En primer lugar, tendrás que asegurarte de que Nginx, MariaDB, PHP y otras extensiones de PHP están instalados en tu sistema. Si no están instalados, puedes instalarlos con el siguiente comando:

apt-get install nginx mariadb-server php php-cli php-fpm php-json php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath unzip curl -y

Una vez instalados todos los paquetes, edita el archivo php.ini y modifica algunos ajustes predeterminados:

nano /etc/php/8.1/fpm/php.ini

Cambia los siguientes ajustes según tus necesidades:

memory_limit = 256M
post_max_size = 64M
upload_max_filesize = 32M
date.timezone = UTC 

Guarda y cierra el archivo, luego reinicia el servicio PHP-FPM para aplicar los cambios:

systemctl restart php8.1-fpm

Configurar la base de datos MariaDB

A continuación, tendrás que crear una base de datos y un usuario para Elgg. Para ello, inicia sesión en MySQL con el siguiente comando:

mysql

Una vez que hayas iniciado sesión, crea una base de datos y un usuario con el siguiente comando:

CREATE DATABASE elggdb;
CREATE USER elgguser@localhost IDENTIFIED BY 'securepassword';

A continuación, concede todos los privilegios a la base de datos de Elgg con el siguiente comando:

GRANT ALL PRIVILEGES ON elggdb.* TO elgguser@localhost;

A continuación, vacía los privilegios y sal de MySQL con el siguiente comando:

FLUSH PRIVILEGES;
EXIT;

En este punto, la base de datos MariaDB y el usuario están creados para Elgg. Ahora puedes proceder al siguiente paso.

Instalar Elgg Ubuntu 22.04

A continuación, tendrás que descargar la última versión de Elgg desde el sitio web Github. Puedes descargarla con el siguiente comando:

wget https://github.com/Elgg/Elgg/releases/download/4.2.3/elgg-4.2.3.zip

Una vez finalizada la descarga, extrae el archivo descargado con el siguiente comando:

unzip elgg-*.zip

A continuación, mueve el directorio extraído al directorio raíz de la web Nginx con el siguiente comando:

mv elgg-4.2.3 /var/www/html/elgg

A continuación, crea un directorio de datos para Elgg y establece la propiedad adecuada para el directorio de datos y el directorio elgg:

mkdir /var/www/html/data
chown -R www-data:www-data /var/www/html/elgg/
chown -R www-data:www-data /var/www/html/data
chmod -R 755 /var/www/html/elgg

En este punto, Elgg se descarga en el directorio raíz web de Nginx. Ahora puedes pasar al siguiente paso.

Crear un host virtual Nginx para Elgg

A continuación, tendrás que crear un archivo de configuración de host virtual Nginx para alojar Elgg en Internet. Puedes crearlo con el siguiente comando:

nano /etc/nginx/conf.d/elgg.conf

Añade las siguientes líneas:

server {
  listen 80;

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

  index index.php;
  
  access_log /var/log/nginx/elgg_access.log;
  error_log /var/log/nginx/elgg_error.log;

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

  location ~ \.php$ {
    fastcgi_index index.php;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    fastcgi_keep_conn on;
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  }
}

Guarda y cierra el archivo, luego verifica el Nginx por si hay algún error de sintaxis:

nginx -t

Deberías ver la siguiente salida:

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

A continuación, reinicia el servicio Nginx con el siguiente comando:

systemctl restart nginx

Puedes comprobar el estado del servicio Nginx con el siguiente comando:

systemctl status nginx

Deberías ver la siguiente salida:

? 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 Mon 2022-07-18 05:53:15 UTC; 6s ago
       Docs: man:nginx(8)
    Process: 18028 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 18029 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 18031 (nginx)
      Tasks: 3 (limit: 4579)
     Memory: 3.3M
        CPU: 53ms
     CGroup: /system.slice/nginx.service
             ??18031 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
             ??18032 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ??18033 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Jul 18 05:53:15 ubuntu2204 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jul 18 05:53:15 ubuntu2204 systemd[1]: Started A high performance web server and a reverse proxy server.

Accede a la Interfaz Web de Elgg

En este punto, Elgg está instalado y configurado con Nginx. Ahora, abre tu navegador web y accede a la interfaz web de Elgg utilizando la URL http://elgg.example.com. Serás redirigido a la página de bienvenida de Elgg:

Haz clic en el botón Siguiente. Deberías ver la página de comprobación de requisitos de PHP:

Asegúrate de que todos los requisitos están instalados y pulsa el botón Siguiente. Deberías ver la página de configuración de la base de datos:

Proporciona la información de tu base de datos, directorio de datos, URL del sitio, y pulsa el botón Siguiente. Deberías ver la página de configuración del sitio:

Proporciona la información de tu sitio y pulsa el botón Siguiente. Deberías ver la página de creación del usuario administrador de Elgg:

Proporciona tu nombre de usuario administrador, correo electrónico, contraseña y haz clic en el botón Siguiente. Una vez que la instalación se haya completado con éxito, deberías ver la siguiente página:

Deberías ver el panel de control de Elgg en la siguiente página:

Habilitar Let’s Encrypt SSL en Elgg

Siempre es una buena idea asegurar tu sitio web con Let’s Encrypt SSL. Primero, instala el cliente Let’s Encrypt de Certbot en tu servidor con el siguiente comando:

apt-get install python3-certbot-nginx -y

Una vez instalado Certbot, protege tu sitio web con Let’s Encrypt SSL ejecutando el siguiente comando:

certbot --nginx -d elgg.example.com

Se te pedirá que proporciones una dirección de correo electrónico válida 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 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 elgg.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/elgg.conf

A continuación, elige si deseas 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

Escribe 2 y pulsa Intro para finalizar la instalación. Deberías ver el siguiente resultado:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/elgg.conf

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

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

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

Conclusión

Enhorabuena! has instalado con éxito Elgg con Nginx y Let’s Encrypt SSL en Ubuntu 22.04. Ahora puedes instalar Elgg en tu escuela, colegio o universidad y crear tu propia plataforma de redes sociales. No dudes en preguntarme si tienes alguna duda.

También te podría gustar...