#!/bin/bash set -e echo "=== Guidly VPS Setup ===" echo "Run this script once on a fresh Ubuntu 22/24 server" # 1. Update system echo ">>> Updating system..." apt update && apt upgrade -y # 2. Install Node.js 22 (LTS) echo ">>> Installing Node.js 22..." curl -fsSL https://deb.nodesource.com/setup_22.x | bash - apt install -y nodejs # 3. Install nginx echo ">>> Installing nginx..." apt install -y nginx # 4. Install certbot for Let's Encrypt SSL echo ">>> Installing certbot..." apt install -y certbot python3-certbot-nginx # 5. Install PM2 globally echo ">>> Installing PM2..." npm install -g pm2 # 6. Create app directory echo ">>> Creating app directory..." mkdir -p /root/guidly # 7. Configure firewall (if ufw is active) if command -v ufw &> /dev/null; then echo ">>> Configuring firewall..." ufw allow 'Nginx Full' ufw allow OpenSSH fi echo "" echo "=== Setup complete ===" echo "" echo "Next steps:" echo " 1. Point DNS: gidli.ru → $(curl -s ifconfig.me)" echo " 2. Copy nginx config: cp /root/guidly/deploy/nginx-guidly.conf /etc/nginx/sites-available/gidli.ru" echo " 3. Enable site: ln -s /etc/nginx/sites-available/gidli.ru /etc/nginx/sites-enabled/" echo " 4. Remove default: rm -f /etc/nginx/sites-enabled/default" echo " 5. Get SSL cert: certbot --nginx -d gidli.ru" echo " 6. Test nginx: nginx -t && systemctl reload nginx" echo " 7. Deploy app: run deploy.sh from your local machine"