En este tutorial, le mostraremos cómo instalar Apache con Let’s Encrypt en Ubuntu 22.04 en Ubuntu 22.04 LTS. Para aquellos de ustedes que no sabían, Let’s Encrypt es una autoridad de certificación sin fines de lucro que proporciona certificados para que sus sitios web puedan utilizar conexiones seguras. Certbot es una herramienta de software de código abierto para integrar y administrar Let’s Encrypt certificados en la web para habilitar un protocolo HTTPS seguro. Administrará automáticamente la Let’s Encrypt certificado para usted.
Este artículo asume que tiene al menos un conocimiento básico de Linux, sabe cómo usar el shell y, lo que es más importante, aloja su sitio en su propio VPS. La instalación es bastante simple y se supone que está ejecutando en la cuenta raíz, si no, es posible que deba agregar ‘ sudo
‘ a los comandos para obtener privilegios de root. Te mostraré el paso a paso de la instalación del Apache con Let’s Encrypt en Ubuntu 22.04 en Ubuntu 22.04 (Jammy Jellyfish). Puede seguir las mismas instrucciones para Ubuntu 22.04 y cualquier otra distribución basada en Debian como Linux Mint, Elementary OS, Pop!_OS y más.
requisitos previos
- Un servidor que ejecuta uno de los siguientes sistemas operativos: Ubuntu 22.04, 20.04 y cualquier otra distribución basada en Debian como Linux Mint.
- Se recomienda que utilice una instalación de sistema operativo nueva para evitar posibles problemas.
- Acceso SSH al servidor (o simplemente abra la Terminal si está en una computadora de escritorio).
- A
non-root sudo user
o acceder a laroot user
. Recomendamos actuar como unnon-root sudo user
sin embargo, puede dañar su sistema si no tiene cuidado al actuar como raíz.
Instalar Apache con Let’s Encrypt en Ubuntu 22.04 LTS Jammy Jellyfish
Paso 1. Primero, asegúrese de que todos los paquetes de su sistema estén actualizados ejecutando lo siguiente apt
Comandos en la terminal.
sudo apt update sudo apt upgrade
Paso 2. Instalación Apache Servidor HTTP en Ubuntu 22.04.
Por defecto, el Apache está disponible en el repositorio base de Ubuntu 22.04. Ahora ejecute el siguiente comando a continuación para instalar la última versión de Apache a su sistema Ubuntu:
sudo apt install apache2
Después de la instalación exitosa, habilite Apache (para iniciar automáticamente al iniciar el sistema), inicie y verifique el estado con los siguientes comandos:
sudo systemctl enable apache2 sudo systemctl start apache2 sudo systemctl status apache2
Puede confirmar la versión de Apache2 con el siguiente comando:
apache2 -v
Paso 3. Configure el cortafuegos.
Ahora configuramos un cortafuegos sin complicaciones (UFW) con Apache para permitir el acceso público a los puertos web predeterminados para HTTP y HTTPS:
sudo ufw allow OpenSSH sudo ufw allow 'Apache Full' sudo ufw enable
Paso 4. Acceso Apache Servidor web.
Una vez que se haya instalado correctamente, abra un navegador web en su sistema y escriba la IP del servidor en la barra de direcciones. Obtendrá el valor predeterminado Apache página del servidor:
Paso 5. Crear Apache Anfitrión virtual.
Primero, cree un directorio raíz para almacenar los archivos de su sitio web:
sudo mkdir -p /var/www/html/domain.com/
Luego, cambie la propiedad y el grupo del directorio:
sudo chown -R www-data:www-data /var/www/html/domain.com/
Después de eso, creamos un Apache host virtual para servir la versión HTTP del sitio web:
sudo nano /etc/apache2/sites-available/www.domain.com.conf
Agregue el siguiente archivo:
<VirtualHost *:80> ServerName domain.com ServerAlias www.domain.com ServerAdmin [email protected] DocumentRoot /var/www/html/www.domain.com ErrorLog ${APACHE_LOG_DIR}/www.domain.com_error.log CustomLog ${APACHE_LOG_DIR}/www.domain.com_access.log combined <Directory /var/www/html/www.domain.com> Options FollowSymlinks AllowOverride All Require all granted </Directory> </VirtualHost>
Guardar y close el archivo, luego reinicie el Apache webserver para que se produzcan los cambios:
sudo a2ensite www.domain.com.conf sudo a2enmod ssl rewrite sudo systemctl restart apache2
Paso 6. Seguro Apache con Let’s Encrypt en Ubuntu 22.04.
En primer lugar, debe instalar Certbot para obtener un certificado SSL con Let’s Encrypt:
sudo apt install certbot python3-certbot-apache
A continuación, obtenga su certificado SSL con Let’s Encrypt siguiendo estos pasos:
sudo certbot --apache
Deberá seguir las indicaciones interactivas e instalar el certificado. Como tengo dos dominios, instalaré certificados SSL para ambos dominios:
Saving debug log to /var/log/letsencrypt/letsencrypt.log 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. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, 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 Account registered. Which names would you like to activate HTTPS for? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: domain.com 2: www.domain.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate numbers separated by commas and/or spaces, or leave input blank to select all options shown (Enter 'c' to cancel): 1,2 Requesting a certificate for domain.com and www.domain.com Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/domain.com/fullchain.pem Key is saved at: /etc/letsencrypt/live/domain.com/privkey.pem This certificate expires on 2022-12-10. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background. Deploying certificate Successfully deployed certificate for domain.com to /etc/apache2/sites-available/www.domain.com-le-ssl.conf Successfully deployed certificate for www.domain.com to /etc/apache2/sites-available/www.domain.com-le-ssl.conf Congratulations! You have successfully enabled HTTPS on https://domain.com and https://www.domain.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Paso 7. Renovación automática de SSL.
Let’s Encrypt los certificados tienen 90 días de validez, siendo muy recomendable renovar los certificados antes de que caduquen. Puede probar la renovación automática de sus certificados ejecutando este comando:
sudo certbot renew --dry-run
Producción:
Saving debug log to /var/log/letsencrypt/letsencrypt.log - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Processing /etc/letsencrypt/renewal/domain.com.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Account registered. Simulating renewal of an existing certificate for domain.com and www.domain.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations, all simulated renewals succeeded: /etc/letsencrypt/live/domain.com/fullchain.pem (success) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Paso 8. Prueba SSL.
Una vez completado con éxito seguro Apache con Let’s Encrypt SSL, ahora ve a ssllabs.com/ssltest/ y ejecute una prueba de SSL en su dominio:
¡Felicidades! Ha configurado con éxito Apache con Let’s Encrypt en Ubuntu 22.04. Gracias por usar este tutorial para instalar el Apache con Let’s Encrypt TLS/SSL en sistema Ubuntu 22.04 LTS Jammy Jellyfish. Para obtener ayuda adicional o información útil, le recomendamos que consulte el oficial Apache sitio web .