Cómo instalar Drupal con Apache y Let’s Encrypt SSL en Debian 11

Elige lengua

Drupal es un sistema de gestión de contenido gratuito y de código abierto basado en la pila LAMP. Drupal tiene excelentes características estándar que le permiten crear poderosos sitios web y blogs. Viene con muchos temas, complementos y widgets que lo ayudan a crear un sitio web sin ningún conocimiento de programación. Proporciona una gran cantidad de funciones, como soporte para múltiples sitios, soporte para varios idiomas, sistema de comentarios, fuente RSS, registro de usuarios y más.

En esta publicación, le mostraremos cómo instalar Drupal CMS con Apache y Let’s Encrypt SSL en Debian 11.

requisitos previos

  • Un servidor que ejecuta Debian 11.
  • Un nombre de dominio válido apuntado con la IP de su servidor.
  • Una contraseña de root está configurada en el servidor.

Instalar la pila LAMP

Drupal se basa en la pila LAMP. Por lo tanto, la pila LAMP debe estar instalada en su servidor. Si no está instalado, puede instalarlo ejecutando el siguiente comando:

apt-get install apache2 mariadb-server mariadb-client php libapache2-mod-php php-cli php-mysql php-zip php-gd php-fpm php-json php-common php-intl php-mbstring php-curl php-xml php-pear php-tidy php-soap php-bcmath php-xmlrpc -y

Una vez que la pila LAMP esté instalada, edite el archivo php.ini y cambie algunas configuraciones predeterminadas:

nano /etc/php/7.4/apache2/php.ini

Cambia las siguientes líneas:

memory_limit = 256M
upload_max_filesize = 32M
max_execution_time = 300
date.timezone = Asia/Kolkata

Guarde y cierre el archivo cuando haya terminado.

Crear una base de datos Drupal

Drupal utiliza MariaDB como base de datos. Por lo tanto, deberá crear una base de datos y un usuario para Drupal.

Primero, inicie sesión en MariaDB con el siguiente comando:

mysql

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

MariaDB [(none)]> CREATE DATABASE drupaldb;
MariaDB [(none)]> CREATE USER 'drupaluser'@'localhost' IDENTIFIED BY "securepassword";

Luego, otorga todos los privilegios a la base de datos de Drupal usando el siguiente comando:

MariaDB [(none)]> GRANT ALL ON drupaldb.* TO 'drupaluser'@'localhost' IDENTIFIED BY "securepassword";

A continuación, elimine los privilegios y salga de MariaDB con el siguiente comando:

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

Descargar Drupal

Primero, vaya al sitio web de Drupal, elija la última versión de Drupal y descárguela con el siguiente comando:

wget https://www.drupal.org/download-latest/tar.gz -O drupal.tar.gz

Una vez descargado Drupal, extraiga el archivo descargado con el siguiente comando:

tar -xvf drupal.tar.gz

A continuación, mueva el directorio extraído al directorio raíz predeterminado de Apache:

mv drupal-* /var/www/html/drupal

Luego, cambie la propiedad y el permiso del directorio Drupal usando el siguiente comando:

chown -R www-data:www-data /var/www/html/drupal/
chmod -R 755 /var/www/html/drupal/

Crear un host virtual de Apache para Drupal

A continuación, deberá crear un archivo de configuración de host virtual de Apache para alojar Drupal. Puedes crearlo usando el siguiente comando:

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

Agregue las siguientes líneas:

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

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

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

     <Directory /var/www/html/>
            RewriteEngine on
            RewriteBase /
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
    </Directory>
</VirtualHost>

Guarde y cierre el archivo, luego habilite el host virtual de Drupal y el módulo de reescritura de Apache con el siguiente comando:

a2ensite drupal.conf
a2enmod rewrite

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

systemctl restart apache2

Para verificar el estado de Apache, ejecute el siguiente comando:

systemctl status apache2

Deberías obtener el siguiente resultado:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-09-18 14:59:40 UTC; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 19698 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 19703 (apache2)
      Tasks: 6 (limit: 2341)
     Memory: 15.3M
        CPU: 78ms
     CGroup: /system.slice/apache2.service
             ??19703 /usr/sbin/apache2 -k start
             ??19704 /usr/sbin/apache2 -k start
             ??19705 /usr/sbin/apache2 -k start
             ??19706 /usr/sbin/apache2 -k start
             ??19707 /usr/sbin/apache2 -k start
             ??19708 /usr/sbin/apache2 -k start

En este punto, el servidor web Apache está configurado para servir a Drupal. Ahora puede continuar con el siguiente paso.

Acceder al sitio web de Drupal

Ahora, abra su navegador web y acceda a Drupal usando la URL http://drupal.ejemplo.com. Será redirigido a la siguiente página:

Elige lengua

Elija el idioma inglés y haga clic en el Guardar y continuar botón, debería ver la siguiente imagen:

Perfil de instalación

Seleccione un perfil de instalación y haga clic en el Guardar y continuar botón. Deberías ver la siguiente página:

Configuración de base de datos

En la página Configuración de la base de datos, proporcione todos los detalles necesarios de la base de datos, como el nombre de la base de datos, el nombre de usuario y la contraseña de la base de datos, el host de la base de datos y, a continuación, haga clic en el botón Guardar y continuar botón, debería ver la siguiente imagen:

Información del sitio

Ajustes regionales

En la página de configuración del sitio de Drupal, proporcione el nombre de su sitio, el nombre de usuario y la contraseña del administrador y luego haga clic en el Guardar y continuar botón para comenzar a instalar Drupal. Una vez que Drupal esté instalado, debería ver el tablero de Drupal en la siguiente imagen:

Iniciar sesión en Drupal

Habilite la compatibilidad con Let’s Encrypt SSL en el sitio web de Drupal

Siempre es una buena idea proteger su sitio web con Let’s Encrypt SSL. Primero, deberá instalar el cliente Certbot para instalar y administrar SSL. De forma predeterminada, el paquete Certbot se incluye en el repositorio predeterminado de Debian 11 para que pueda instalarlo con el siguiente comando:

apt-get install python3-certbot-apache -y

Una vez que el Certbot esté instalado, ejecute el siguiente comando para proteger su sitio web con Let’s Encrypt SSL: Publicidad

certbot --apache -d drupal.example.com

Se le pedirá que proporcione su correo electrónico y acepte el término 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 drupal.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/drupal-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/drupal-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/drupal-le-ssl.conf

A continuación, seleccione si desea redirigir o no 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

Escriba 2 y presione Entrar para instalar Let’s Encrypt SSL para su sitio web:

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

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

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

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

Conclusión

Eso es todo por ahora. Ha instalado correctamente Drupal con Let’s Encrypt SSL en Debian 11. Ahora puede comenzar a crear su propio blog o sitio web sin ningún conocimiento de programación. No dude en preguntarme si tiene alguna pregunta.

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *