RamNode logo
AI Development Platform

Deploy Your Bolt App to RamNode VPS

Deploy your Bolt-generated application to a RamNode VPS for full control over your hosting environment and better performance than shared hosting. This comprehensive guide covers the entire deployment process from server setup to production optimization.

Ubuntu 22.04+
Node.js Application
⏱️ 25-35 minutes

Prerequisites

Before starting, ensure you have:

Server Requirements

  • • RamNode VPS account and server
  • • SSH access to your server
  • • Root/sudo privileges
  • • Basic command line knowledge

Application Requirements

  • • Bolt application ready for deployment
  • • Application source code access
  • • Domain name (optional but recommended)
  • • Environment configuration details
2

Initial Server Setup

Connect to your RamNode VPS and prepare the system:

Connect via SSH
ssh root@your-server-ip
Update System Packages
apt update && apt upgrade -y
Create Non-Root User
adduser deployer
usermod -aG sudo deployer
su - deployer

💡 Security: Using a non-root user is a security best practice that limits potential damage from compromises.

3

Install Required Software

Install Node.js, PM2, and Nginx for your Bolt application:

Install Node.js 18.x:

Install Node.js and npm
# Install Node.js 18.x
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify installation
node --version
npm --version

Install PM2 Process Manager:

Install PM2 Globally
sudo npm install -g pm2

Install Nginx:

Install and Configure Nginx
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx

Install Git (if needed):

Install Git
sudo apt install git -y

✅ All required software is now installed and ready for your Bolt application.

4

Deploy Your Bolt Project

Get your Bolt application code onto the server and prepare it for production:

Clone Your Repository:

Git Clone
cd /home/deployer
git clone https://github.com/your-username/your-bolt-app.git
cd your-bolt-app

Alternative: Upload via SCP:

Upload Files (from local machine)
scp -r /path/to/your/bolt-app deployer@your-server-ip:/home/deployer/

Install Dependencies:

Install Node Packages
npm install

Build for Production:

Production Build
npm run build

💡 Note: Some Bolt applications may have different build commands. Check your package.json for the correct build script.

5

Configure Nginx

Set up Nginx as a reverse proxy for your Bolt application:

Create Nginx Site Configuration:

Create Config File
sudo nano /etc/nginx/sites-available/your-bolt-app
Nginx Configuration
server {
 listen 80;
 server_name your-domain.com www.your-domain.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_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-Proto $scheme;
 proxy_cache_bypass $http_upgrade;
 }
 # Handle static files (if served separately)
 location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
 expires 1y;
 add_header Cache-Control "public, immutable";
 try_files $uri @proxy;
 }
 location @proxy {
 proxy_pass http://localhost:3000;
 }
 # Security headers
 add_header X-Frame-Options "SAMEORIGIN" always;
 add_header X-XSS-Protection "1; mode=block" always;
 add_header X-Content-Type-Options "nosniff" always;
 add_header Referrer-Policy "no-referrer-when-downgrade" always;
}

Enable the Site:

Enable and Test Configuration
sudo ln -s /etc/nginx/sites-available/your-bolt-app /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Remove Default Site (Optional):

Remove Default Nginx Site
sudo rm /etc/nginx/sites-enabled/default

💡 Proxy Setup: Nginx acts as a reverse proxy, forwarding requests to your Bolt app running on port 3000.

6

SSL Certificate Setup

Secure your Bolt application with SSL certificates:

Install Certbot:

Install Certbot and Nginx Plugin
sudo apt install snapd -y
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot

Obtain SSL Certificate:

Get SSL Certificate
sudo certbot --nginx -d your-domain.com -d www.your-domain.com

Test Auto-Renewal:

Test Certificate Renewal
sudo certbot renew --dry-run

🔒 Success: Your Bolt app is now secured with HTTPS and auto-renewing SSL certificates.

7

Configure PM2 Process Manager

Use PM2 to keep your Bolt application running and automatically restart it if it crashes:

Create PM2 Ecosystem File:

Create ecosystem.config.js
nano ecosystem.config.js
PM2 Configuration
module.exports = {
 apps: [{
 name: 'bolt-app',
 script: './server.js', // or your main application file
 cwd: '/home/deployer/your-bolt-app',
 instances: 1,
 autorestart: true,
 watch: false,
 max_memory_restart: '1G',
 env: {
 NODE_ENV: 'production',
 PORT: 3000
 },
 env_production: {
 NODE_ENV: 'production',
 PORT: 3000
 }
 }]
};

Start Your Application:

Start with PM2
pm2 start ecosystem.config.js --env production
pm2 save
pm2 startup

PM2 Management Commands:

Useful PM2 Commands
# Check application status
pm2 status
# View logs
pm2 logs bolt-app
# Restart application
pm2 restart bolt-app
# Stop application
pm2 stop bolt-app

🚀 Running: Your Bolt application is now running with PM2 and will automatically restart if it crashes.

8

Environment Variables

Configure environment variables for your Bolt application:

Create Environment File:

Create .env File
nano /home/deployer/your-bolt-app/.env
Sample Environment Configuration
NODE_ENV=production
PORT=3000
DATABASE_URL=your_database_connection_string
API_KEY=your_api_key
SECRET_KEY=your_secret_key
BOLT_ENVIRONMENT=production

Secure Environment File:

Set Proper Permissions
chmod 600 .env
chown deployer:deployer .env

Update PM2 Configuration:

Ensure PM2 loads environment variables:

Update ecosystem.config.js
module.exports = {
 apps: [{
 name: 'bolt-app',
 script: './server.js',
 cwd: '/home/deployer/your-bolt-app',
 instances: 1,
 autorestart: true,
 watch: false,
 max_memory_restart: '1G',
 env_file: '.env', // Load environment file
 env: {
 NODE_ENV: 'production',
 PORT: 3000
 }
 }]
};

🔐 Security: Never commit .env files to version control. Keep sensitive data secure.

9

Automated Deployment Setup

Create deployment scripts for easy updates:

Create Deployment Script:

Create deploy.sh
nano /home/deployer/deploy.sh
Deployment Script
#!/bin/bash
# Set variables
APP_DIR="/home/deployer/your-bolt-app"
APP_NAME="bolt-app"
echo "Starting deployment at $(date)"
# Navigate to app directory
cd $APP_DIR
# Pull latest changes
echo "Pulling latest changes..."
git pull origin main
# Install/update dependencies
echo "Installing dependencies..."
npm install
# Build the application
echo "Building application..."
npm run build
# Restart PM2 application
echo "Restarting application..."
pm2 restart $APP_NAME
# Check application status
echo "Checking application status..."
pm2 status
echo "Deployment completed at $(date)"

Make Script Executable:

Set Permissions
chmod +x /home/deployer/deploy.sh

Run Deployment:

Execute Deployment
./deploy.sh

GitHub Webhook (Optional):

Set up automatic deployments on code push:

Simple Webhook Server
const express = require('express');
const { exec } = require('child_process');
const app = express();
app.use(express.json());
app.post('/webhook', (req, res) => {
 if (req.body.ref === 'refs/heads/main') {
 exec('/home/deployer/deploy.sh', (error, stdout, stderr) => {
 if (error) {
 console.error(`Error: ${error}`);
 return res.status(500).send('Deployment failed');
 }
 console.log(stdout);
 res.send('Deployment successful');
 });
 } else {
 res.send('Not main branch, skipping deployment');
 }
});
app.listen(3001, () => {
 console.log('Webhook server running on port 3001');
});

🚀 Automation: You can now deploy updates with a single command or set up CI/CD pipelines.

10

Monitoring and Logging

Set up monitoring and logging for your Bolt application:

Application Monitoring:

  • • Monitor application performance
  • • Track memory and CPU usage
  • • Monitor response times
  • • Set up error tracking

Server Monitoring:

  • • Monitor disk space
  • • Track server resources
  • • Monitor Nginx logs
  • • Set up uptime monitoring

Useful Monitoring Commands:

System Monitoring Commands
# Check system resources
htop
# Check disk usage
df -h
# Monitor PM2 applications
pm2 monit
# View application logs
pm2 logs bolt-app --lines 100
# Check Nginx logs
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
# Check system logs
sudo journalctl -f

Set Up Log Rotation:

Configure Log Rotation
# PM2 handles log rotation automatically, but you can configure it
pm2 install pm2-logrotate
# Configure log rotation settings
pm2 set pm2-logrotate:max_size 10M
pm2 set pm2-logrotate:retain 30

Troubleshooting Common Issues

🎉 Your Bolt App is Live!

Congratulations! Your Bolt application is now successfully deployed on your RamNode VPS. You have full control over your hosting environment with excellent performance, monitoring, and automated deployment capabilities.

✅ App Deployed
✅ SSL Secured
✅ PM2 Configured
✅ Production Ready

AltStyle によって変換されたページ (->オリジナル) /