Created
February 5, 2024 13:21
-
-
Save leifermendez/d160a1687314e0f0341903d425a87620 to your computer and use it in GitHub Desktop.
install-nginx-sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Actualizar la lista de paquetes disponibles | |
sudo apt update | |
# Instalar Nginx | |
sudo apt install -y nginx | |
# Comprobar si Nginx se instaló correctamente | |
if [ $? -eq 0 ]; then | |
echo "Nginx se ha instalado correctamente." | |
else | |
echo "Ha ocurrido un error durante la instalación de Nginx. Por favor, comprueba los registros para más detalles." | |
exit 1 | |
fi | |
# Iniciar el servicio de Nginx | |
sudo systemctl start nginx | |
# Habilitar Nginx para que se inicie automáticamente en el arranque | |
sudo systemctl enable nginx | |
# Comprobar si el servicio se está ejecutando | |
if systemctl is-active --quiet nginx; then | |
echo "Nginx se está ejecutando correctamente." | |
else | |
echo "Ha ocurrido un error al iniciar Nginx. Por favor, comprueba los registros para más detalles." | |
exit 1 | |
fi | |
# Mensaje final | |
echo "La instalación de Nginx se ha completado correctamente." | |
echo "Si deseas probar la instalación, puedes abrir tu navegador web e ingresar la dirección IP pública del servidor. Deberías ver una página de bienvenida predeterminada de Nginx." | |
# Salida exitosa | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment