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
Initial Server Setup
Connect to your RamNode VPS and prepare the system:
ssh root@your-server-ipapt update && apt upgrade -yadduser deployer
usermod -aG sudo deployer
su - deployer💡 Security: Using a non-root user is a security best practice that limits potential damage from compromises.
Install Required Software
Install Node.js, PM2, and Nginx for your Bolt application:
Install Node.js 18.x:
# 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 --versionInstall PM2 Process Manager:
sudo npm install -g pm2Install Nginx:
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginxInstall Git (if needed):
sudo apt install git -y✅ All required software is now installed and ready for your Bolt application.
Deploy Your Bolt Project
Get your Bolt application code onto the server and prepare it for production:
Clone Your Repository:
cd /home/deployer
git clone https://github.com/your-username/your-bolt-app.git
cd your-bolt-appAlternative: Upload via SCP:
scp -r /path/to/your/bolt-app deployer@your-server-ip:/home/deployer/Install Dependencies:
npm installBuild for Production:
npm run build💡 Note: Some Bolt applications may have different build commands. Check your package.json for the correct build script.
Configure Nginx
Set up Nginx as a reverse proxy for your Bolt application:
Create Nginx Site Configuration:
sudo nano /etc/nginx/sites-available/your-bolt-appserver {
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:
sudo ln -s /etc/nginx/sites-available/your-bolt-app /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginxRemove Default Site (Optional):
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.
SSL Certificate Setup
Secure your Bolt application with SSL certificates:
Install Certbot:
sudo apt install snapd -y
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbotObtain SSL Certificate:
sudo certbot --nginx -d your-domain.com -d www.your-domain.comTest Auto-Renewal:
sudo certbot renew --dry-run🔒 Success: Your Bolt app is now secured with HTTPS and auto-renewing SSL certificates.
Configure PM2 Process Manager
Use PM2 to keep your Bolt application running and automatically restart it if it crashes:
Create PM2 Ecosystem File:
nano ecosystem.config.jsmodule.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:
pm2 start ecosystem.config.js --env production
pm2 save
pm2 startupPM2 Management 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.
Environment Variables
Configure environment variables for your Bolt application:
Create Environment File:
nano /home/deployer/your-bolt-app/.envNODE_ENV=production
PORT=3000
DATABASE_URL=your_database_connection_string
API_KEY=your_api_key
SECRET_KEY=your_secret_key
BOLT_ENVIRONMENT=productionSecure Environment File:
chmod 600 .env
chown deployer:deployer .envUpdate PM2 Configuration:
Ensure PM2 loads environment variables:
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.
Automated Deployment Setup
Create deployment scripts for easy updates:
Create Deployment Script:
nano /home/deployer/deploy.sh#!/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:
chmod +x /home/deployer/deploy.shRun Deployment:
./deploy.shGitHub Webhook (Optional):
Set up automatic deployments on code push:
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.
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:
# 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 -fSet Up 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 30Troubleshooting 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.
