Custom Server Environment
Deploy
Build, run with PM2, and proxy with Nginx
Build the App
From the project root on your server:
pnpm buildThis compiles the Next.js production bundle. Fix any build errors before continuing.
Install and Configure PM2
sudo npm install -g pm2
pm2 start pnpm --name studystudio -- start
pm2 save
pm2 startupThe app now runs on port 3000. Use pm2 logs studystudio to watch output and pm2 restart studystudio after future deploys.
Configure Nginx
Create a server block that proxies to your app. A minimal config:
server {
listen 80;
server_name yourdomain.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;
}
}sudo ln -s /etc/nginx/sites-available/studystudio /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxAdd SSL (Recommended)
Use Certbot for a free TLS certificate:
sudo apt-get install -y certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.comVerify the Live Site
Open your domain and confirm the landing page, /en/admin/login, signup + verification email, a test payment, and /en/docs all work.