1. AWS Lightsail Instance Setup
Create Lightsail Instance
- Go to AWS Lightsail Console
- Click “Create instance”
- Select Linux/Unix platform
- Choose “Ubuntu 22.04 LTS”
- Select an instance plan (recommended: 2 GB RAM, 1 vCPU)
- Name your instance (e.g., “bolt-diy-app”)
- Click “Create instance”
Configure Security
- Go to the Networking tab of your instance
- Add these firewall rules:
- HTTP (Port 80)
- HTTPS (Port 443)
- Custom TCP (Port 3000)
2. Domain Setup
Domain Configuration
- Register your domain or use existing domain
- Add these DNS records:
A Record: @ points to your Lightsail instance IP
A Record: www points to your Lightsail instance IP
3. Server Setup
Initial Server Configuration
# Connect to your instance via SSH
sudo apt update
sudo apt upgrade -y
# Install Node.js and npm
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
# Install development tools
sudo apt install -y git build-essential
# Install pnpm
sudo npm install -g pnpm
# Install PM2 for process management
sudo npm install -g pm2
Install Nginx
# Install Nginx
sudo apt install -y nginx
# Start Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
4. Application Setup
Clone and Configure Application
# Create application directory
cd /var/www
sudo mkdir bolt-diy
sudo chown ubuntu:ubuntu bolt-diy
cd bolt-diy
# Clone the repository
git clone https://github.com/stackblitz-labs/bolt.diy.git .
# Install dependencies
pnpm install
# Build the application
pnpm run build
Environment Setup
# Create environment file
nano .env
# Add necessary environment variables
NODE_ENV=production
PORT=3000
5. Nginx Configuration
Create Nginx Configuration
sudo nano /etc/nginx/sites-available/bolt-diy
Add this configuration:
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Enable the Site
# Enable the site
sudo ln -s /etc/nginx/sites-available/bolt-diy /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
# Test Nginx configuration
sudo nginx -t
# Restart Nginx
sudo systemctl restart nginx
6. SSL Configuration
Install Certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
# Get SSL certificate
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
# Enable auto-renewal
sudo systemctl enable certbot.timer
7. Start the Application
Run with PM2
# Start the application
cd /var/www/bolt-diy
pm2 start npm --name "bolt-diy" -- start
# Save PM2 configuration
pm2 save
# Enable PM2 startup script
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u ubuntu --hp /home/ubuntu
8. Maintenance Commands
Update Application
cd /var/www/bolt-diy
git pull
pnpm install
pnpm run build
pm2 restart bolt-diy
View Logs
# View application logs
pm2 logs bolt-diy
# View Nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
9. Important Notes
- Replace
yourdomain.com
with your actual domain name in the Nginx configuration - Keep your API keys secure and never commit them to the repository
- Regularly update your system packages using
sudo apt update && sudo apt upgrade
- Monitor your application’s performance and logs
- Set up regular backups of your application data