Cómo instalar un foro phpBB con Apache y SSL gratuito Let’s Encrypt en Ubuntu 22.04

phpBB es un software de foros gratuito y de código abierto que proporciona un espacio para que la gente se reúna y se comunique entre sí. Está escrito en PHP y utiliza MariaDB como base de datos. Ofrece un amplio conjunto de funciones, como subforos, grupos de usuarios, búsqueda de texto completo, plugins y notificaciones por correo electrónico. Es totalmente escalable y personalizable, y tiene una interfaz fácil de usar y sencillas opciones de gestión.

Este post te mostrará cómo instalar phpBB con Apache 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.

Instalar Apache, MariaDB y PHP

En primer lugar, tendrás que instalar en tu servidor el servidor web Apache, el servidor de bases de datos MariaDB, PHP y otros paquetes. Puedes instalarlos todos ejecutando el siguiente comando:

apt install apache2 mariadb-server php libapache2-mod-php php-gd php-curl openssl php-imagick php-intl php-json php-ldap php-common php-mbstring php-mysql php-imap php-sqlite3 php-net-ftp php-zip unzip php-pgsql php-ssh2 php-xml wget unzip -y

Una vez instalados todos los paquetes, inicia y habilita el servicio Apache con el siguiente comando:

systemctl start apache2
systemctl enable apache2

Crear una base de datos para phpBB

phpBB utiliza MariaDB para almacenar sus datos. Así que necesitarás crear una base de datos y un usuario para phpBB. Primero, inicia sesión en el shell de MariaDB con el siguiente comando:

mysql

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

MariaDB [(none)]> CREATE DATABASE phpdb;
MariaDB [(none)]> GRANT ALL ON phpdb.* to 'phpuser'@'localhost' IDENTIFIED BY 'password';

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

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

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

Descargar phpBB

A continuación, tendrás que descargar la última versión de phpBB desde su página oficial de descargas. Puedes descargarla con el siguiente comando:

wget https://download.phpbb.com/pub/release/3.3/3.3.7/phpBB-3.3.7.zip

Una vez descargado el phpBB, descomprime el archivo descargado con el siguiente comando:

unzip phpBB-3.3.7.zip

A continuación, mueve el directorio extraído al directorio raíz de la web Apache:

mv phpBB3 /var/www/html/phpbb

A continuación, cambia la propiedad y el permiso del directorio phpbb:

chown -R www-data:www-data /var/www/html/phpbb
chmod -R 775 /var/www/html/phpbb

Una vez hecho esto, puedes pasar al siguiente paso.

Configurar Apache para phpBB

A continuación, debes crear un archivo de configuración del host virtual de Apache para alojar phpBB. Puedes crearlo con el siguiente comando:

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

Añade las siguientes líneas:

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

      <Directory /var/www/html/phpbb>
                Options FollowSymlinks
                AllowOverride All
                Require all granted
       </Directory>

ErrorLog ${APACHE_LOG_DIR}/phpbb_error.log
CustomLog ${APACHE_LOG_DIR}/phpbb_access.log combined


</VirtualHost>

Guarda y cierra el archivo cuando hayas terminado, luego habilita el host virtual de Apache y el módulo de reescritura con el siguiente comando:

a2ensite phpbb
a2enmod rewrite

A continuación, reinicia el servicio Apache para aplicar los cambios:

systemctl restart apache2

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

systemctl status apache2

Obtendrás la siguiente salida:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-05-28 10:50:04 UTC; 2s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 22212 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 22217 (apache2)
      Tasks: 6 (limit: 2292)
     Memory: 15.8M
        CPU: 98ms
     CGroup: /system.slice/apache2.service
             ??22217 /usr/sbin/apache2 -k start
             ??22218 /usr/sbin/apache2 -k start
             ??22219 /usr/sbin/apache2 -k start
             ??22220 /usr/sbin/apache2 -k start
             ??22221 /usr/sbin/apache2 -k start
             ??22222 /usr/sbin/apache2 -k start

May 28 10:50:04 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...

Accede a la Interfaz Web de phpBB

Ahora, abre tu navegador web y accede a la interfaz web de phpBB utilizando la URL http://phpbb.example.com. Deberías ver la siguiente página:

Haz clic en la pestaña INSTALAR y pulsa el botón Instalar para iniciar la instalación. Deberías ver la siguiente página:

Introduce tu nombre de usuario y contraseña de administrador y haz clic en el botón Enviar. Deberías ver la siguiente página:

Indica el host de la base de datos, el puerto, el nombre de la base de datos, el nombre de usuario, la contraseña y pulsa el botón Enviar. Deberías ver la siguiente página:

Proporciona tu protocolo, nombre del dominio del sitio web, puerto, ruta y pulsa el botón Enviar. Deberías ver la siguiente página:

Proporciona los detalles de tu SMTP y pulsa el botón Enviar. Deberías ver la siguiente página:

Selecciona tu idioma, el nombre del foro, la descripción del foro y haz clic en el botón Enviar. Deberías ver la siguiente página:

Haz clic en el botón Llévame al ACP. Deberías ver el panel de control phpBB en la siguiente página:

Proteger phpBB con Let’s Encrypt SSL

Siempre es una buena idea asegurar tu sitio web con Let’s Encrypt SSL. Necesitarás instalar el cliente Certbot para instalar y gestionar el SSL. Puedes instalarlo con el siguiente comando:

apt-get install python3-certbot-apache -y

Una vez instalado Certbot, ejecuta el siguiente comando para proteger tu sitio web con Let’s Encrypt SSL:

certbot --apache -d phpbb.example.com

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

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
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
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for phpbb.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/phpbb-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/phpbb-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/phpbb-le-ssl.conf

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

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 instalar el SSL de Let’s Encrypt para tu sitio web:

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

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

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

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

Ahora, puedes acceder a tu sitio web de forma segura utilizando la URL https://phpbb.example.com.

Conclusión

Enhorabuena! has instalado correctamente phpBB con Apache y Let’s Encrypt SSL en Ubuntu 22.04. Ahora puedes explorar el panel de control de phpBB y empezar a crear tu primer foro.

Scroll al inicio