Nginx es uno de los servidores web más rápidos y eficientes para entornos Linux. En esta guía aprenderás a:
- Instalar y configurar Nginx en AlmaLinux
- Habilitar HTTPS con Let’s Encrypt
- Optimizar el rendimiento para producción
- Solucionar errores comunes
🛠️ Instalación de Nginx #
- Instalar desde repositoriosbash
1sudo dnf install nginx -y - Iniciar y habilitar el serviciobash
1sudo systemctl enable --now nginx - Verificar instalaciónDeberías ver: HTTP/1.1 200 OKbash
1curl -I localhost
📂 Configuración Básica #
Estructura de archivos clave #
| Ruta | Propósito |
|---|---|
| /etc/nginx/nginx.conf | Configuración principal |
| /etc/nginx/conf.d/ | Configs de sitios adicionales |
| /var/www/html/ | Directorio raíz por defecto |
Ejemplo de configuración mínima #
conf
| |
Verificar y recargar:
bash
| |
🔒 Certificado SSL con Let’s Encrypt #
- Instalar Certbotbash
1sudo dnf install certbot python3-certbot-nginx -y - Obtener certificadobash
1sudo certbot --nginx -d tusitio.com -d www.tusitio.com - Renovación automática
Añadir al cron:bash
10 3 \* \* \* /usr/bin/certbot renew --quiet
⚡ Optimización de Rendimiento #
Ajustes recomendados en /etc/nginx/nginx.conf #
conf
| |
Comandos útiles #
bash
| |
🚨 Solución de Problemas Comunes #
Error: “Port 80 already in use” #
bash
| |
Error: “SSL handshake failed” #
Verificar que el puerto 443 esté abierto:
bash
| |
📊 Comparativa Nginx vs Apache #
| Característica | Nginx | Apache |
|---|---|---|
| Velocidad | Rapido | Lento |
| Rendimiento | Alto | Medio |
| Consumo RAM | Bajo | Moderado |
| Facilidad | Intermedia | Sencilla |
| Soporte .htaccess | No | Sí |
📌 Conclusión #
Con esta guía has aprendido a:
- Desplegar Nginx en AlmaLinux
- Configurar sitios virtuales
- Implementar HTTPS automático
- Optimizar para entornos productivos



