Importante
Este artículo está obsoleto y puede contener información desactualizada. Por favor, consulta la documentación más reciente para obtener la información actualizada.
Drupal es un sistema de gestión de contenido de código abierto escrito en PHP y utilizado por individuos o grupos de usuarios. Con Drupal puedes crear y administrar muchos tipos de sitios web. Drupal puede ejecutarse en cualquier sistema operativo que admita un servidor web, un servidor de base de datos y es capaz de ejecutar PHP.
En este tutorial, te explicamos cómo instalar Drupal en el servidor Ubuntu 18.04 y protegerlo con Let’s Encrypt free SSL.
Requisitos
- Un servidor cloud vps corriendo con Ubuntu 18.04.
- Un nombre de dominio válido apuntando a la IP de tu servidor cloud.
- Una contraseña root configurada en tu servidor vps cloud,
Instala Apache, MariaDB y PHP
Drupal se ejecuta en un servidor web, escrito en PHP y utiliza MariaDB para almacenar sus datos. Por lo tanto, deberás instalar Apache, MariaDB, PHP y otros paquetes necesarios en tu servidor cloud. Puedes instalarlos todos con el siguiente comando:
# apt-get install apache2 mariadb-server mariadb-client php7.2 libapache2-mod-php7.2 php7.2-common php7.2-mysql php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-gd php7.2-xml php7.2-cli php7.2-zip unzip -y
Una vez que todos los paquetes estén instalados, abre el archivo php.ini y ajusta algunas configuraciones de PHP:
# nano /etc/php/7.2/apache2/php.ini
Cambia las siguientes líneas:
memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = America/Chicago
Guarda y cierra el archivo cuando hayas terminado.
Configura la Base de Datos de Drupal
A continuación, necesitarás crear la base de datos y el usuario para Drupal. Para ello, haz entra en el shell de MariaDB con el siguiente comando:
# mysql -u root -p
Propociona tu contraseña de root, después crea un usuario y una base de datos para Drupal:
MariaDB [(none)]> CREATE DATABASE drupal;
MariaDB [(none)]> CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'password';
A continuación, concede todos los privilegios a la base de datos de Drupal con el siguiente comando:
# MariaDB [(none)]> GRANT ALL ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
Después, descarga los privilegios y sal del shell de MariaDB con el siguiente comando:
# MariaDB [(none)]> FLUSH PRIVILEGES;
# MariaDB [(none)]> EXIT;
Una vez que hayas terminado, puedes proceder al siguiente paso.
Descarga Drupal
A continuación, necesitarás descargar la última versión de Drupal de su website oficial. Puedes hacerlo con el siguiente comando:
# wget https://www.drupal.org/download-latest/zip -O drupal.zip
Una vez descargada, descomprime el archivo descargado con el siguiente comando:
# unzip drupal.zip
A continuación, mueve el directorio extraído al directorio root de Apache:
mv drupal-8.7.8 /var/www/html/drupal
Después, cambia la propiedad del directorio de Drupal a www-data y dale los permisos necesarios:
# chown -R www-data:www-data /var/www/html/drupal # chmod -R 755 /var/www/html/drupal
Configura Apache para Drupal
A continuación, necesitarás crear un archivo de configuración virtual host Apache para Drupal.
Puedes crearlo con el siguiente comando:
# nano /etc/apache2/sites-available/example.com.conf
Añade las siguientes líneas:
<VirtualHost *:80>
ServerName example.com
ServerAdmin admin@example.com
DocumentRoot /var/www/html/drupal
<Directory /var/www/html/drupal/>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/drupal/>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*) index.php [PT,L]
</Directory>
</VirtualHost>
Guarda y cierra el archivo. Después, habilita el host y reescribe Apache con los siguientes comandos:
# a2ensite example.com
# a2enmode rewrite
Después, reinicia el servicio de Apache para aplicar los cambios:
# systemctl restart apache2
Accede a la Interfaz Web de Drupal
Ahora abre tu navegador web y visita la URL http://ejemplo.com. Serás redirigido a la siguiente página:
Selecciona el idioma deseado y haz clic en la pestaña de “Guardar y continuar”. Deberías ver la siguiente página:
Selecciona un perfil de instalación y haz clic en la pestaña “Guardar y continuar”. Deberías ver la siguiente página:
Proporciona la información de la base de datos y haz clic en la pestaña “Guardar y continuar”. Deberías ver la siguiente página:
Ahora, proporciona el nombre de tu website, usuario admin, contraseña, e-mail admin y haz clic en la pestaña “Guardar y Continuar”. Una vez que la instalación haya finalizado, deberías ver el panel de control por defecto de Drupal en la siguiente página:
Asegura Drupal con Let’s Encrypt
A continuación, necesitarás asegurar el site de Drupal con el certificado SSL gratis de Let´s Encrypt. Para hacerlo, necesitarás instalar el cliente Certbot en tu sistema. Por defecto, la última versión de Certbot no está disponible en el repositorio por defecto de Ubuntu 18.04.
Primero, añade el repositorio Certbot con el siguiente comando:
# add-apt-repository ppa:certbot/certbot
A continuación, actualiza el repositorio e instala Certbot con el módulo Apache con el siguiente comando:
# apt-get update -y
# apt-get install certbot python-certbot-apache
Una vez que la instalación se haya completado, descarga el certificado SSL de Let´s Encrypt para tu dominio ejemplo.com y configura Apache para usar este certificado con el siguiente comando:
# certbot --apache -d example.com
Se te pedirá que proporciones tu dirección de e-mail y que estés de acuerso con los términos y condiciones que se muestran más abajo:
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): admin@example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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: N
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for example.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/example.com-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/example.com-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/example.com-le-ssl.conf
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
Aquí tendrás que escoger entre redirigir o no el tráfico HTTP a HTTPS. Escoge la opción 2 y dale a “Enter” para continuar. Una vez que se haya completado la instalación, deberías ver el siguiente resultado:
Added an HTTP->HTTPS rewrite in addition to other RewriteRules; you may wish to check for overall consistency. Redirecting vhost in /etc/apache2/sites-enabled/example.com.conf to ssl vhost in /etc/apache2/sites-available/example.com-le-ssl.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled
https://example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/example.com/privkey.pem
Your cert will expire on 2020-01-09. 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
¡Enhorabuena! Tu site con Drupal ha sido securizada con el certificado SSL gratuito de Let’s Encrypt. Puedes acceder de forma segura visitando la URL https://ejemplo.com.