Install y configure Nginx in your VPS

Why Nginx?

Nginx es el servidor web más usado in the mundo. Es más rápido and eficiente que Apache for sitios with mucho tráfico, consume menos memory and es ideal for servir files estáticos and actuar like proxy reverso.

Install 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

Configure un website (Virtual Host)

Crea un file de settings for your domain:

nano /etc/nginx/conf.d/tudomain.conf

Paste esta settings básica:

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

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

Comandos basics de Nginx

systemctl start nginx # Iniciar
systemctl stop nginx # Detener
systemctl restart nginx # Restartr
nginx -t # Probar settings
⚠️ Always prueba la settings with nginx -t before de reiniciar. Un error de sintaxis puede dejar your servidor web caído.