Requirements
- A REGTR cloud server (Ubuntu 24.04)
- A domain with an A record pointing to the server IP
- A sudo user
Steps
-
1Install Node.js 22 LTS
Install the current LTS from the NodeSource repository.
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - sudo apt install -y nodejs git node -v -
2Fetch and build the app
Clone your repository, install dependencies and build for production.
git clone https://github.com/KULLANICI/PROJE.git ~/web cd ~/web npm ci npm run build -
3Run with PM2
The app restarts if it crashes and starts on boot. Run the line printed by pm2 startup.
sudo npm install -g pm2 pm2 start npm --name web -- start pm2 startup systemd pm2 save -
4Nginx reverse proxy
Nginx forwards requests from port 80 to the app on port 3000.
sudo apt install -y nginx sudo tee /etc/nginx/sites-available/web >/dev/null <<'EOF' server { listen 80; server_name example.com www.example.com; location / { proxy_pass http://127.0.0.1:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } } EOF sudo ln -s /etc/nginx/sites-available/web /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx -
5Free SSL
Certbot obtains the certificate, configures Nginx for HTTPS and renews automatically.
sudo apt install -y certbot python3-certbot-nginx sudo certbot --nginx -d example.com -d www.example.com
Tips
- Don't expose port 3000; access the app only through Nginx (keep 3000 closed in UFW).
- Keep environment variables in a .env file and out of the repository.
- With "output: standalone" Next.js produces a smaller build that starts faster.
FAQ
Which plan is enough?
A single Next.js app runs fine on 2 vCPU / 4 GB (ARM 2). If you build on the server and traffic is high, choose 4 vCPU / 8 GB.
Docker or PM2?
PM2 is simpler for one app. With multiple services or a database, Docker Compose or Coolify keeps things tidier.
Updated: 2026-10-23