Installare y configurare Nginx nel tuo VPS

Perché Nginx?

Nginx es el servidor web más usado nel mundo. Es más rápido e eficiente que Apache per sitios con mucho tráfico, consume menos memoria e es ideal per servir file estáticos e actuar come proxy reverso.

Installare Nginx

En Ubuntu/Debian:

apt update
apt install nginx -y
systemctl start nginx
systemctl enable nginx

En AlmaLinux/CentOS:

yum install nginx -y
systemctl start nginx
systemctl enable nginx

Configuraree un sito web (Virtual Host)

Crea un file de impostazioni per tu dominio:

nano /etc/nginx/conf.d/tudominio.conf

Incolla esta impostazioni básica:

server {
  listen 80;
  server_name tudominio.com www.tudominio.com;
  root /var/www/tudominio;
  index index.php index.html;

  location / {
    try_files $uri $uri/ =404;
  }
}

Comandos bases de Nginx

systemctl start nginx # Iniciar
systemctl stop nginx # Detener
systemctl restart nginx # Riavviar
nginx -t # Probar impostazioni
⚠️ Sempre prueba la impostazioni con nginx -t prima de reiniciar. Un erroree de sintaxis puede dejar tu servidor web caído.