Prerequisites
Before starting, ensure you have:
Server Requirements
- • RamNode VPS (1GB+ RAM minimum)
- • Ubuntu 20.04/22.04 or Debian 11
- • 1 CPU core minimum
- • SSH access to your VPS
- • Domain name (optional, recommended)
Knowledge Requirements
- • Basic Linux command line
- • Understanding of web servers
- • Basic networking concepts
- • SSH connection skills
Initial Server Setup
Connect to your RamNode VPS and prepare the environment:
ssh root@your-server-ipapt update && apt upgrade -yadduser n8n
usermod -aG sudo n8nsu - n8n💡 Security Tip: Running N8N as a dedicated user improves security by limiting permissions and isolating the application.
Install Node.js and npm
N8N requires Node.js to run. Install the latest LTS version:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -sudo apt-get install -y nodejsnode --version
npm --version✅ Node.js is now installed and ready for N8N deployment!
Install N8N
Install N8N globally using npm:
sudo npm install n8n -gn8n --versionWhat is N8N?
N8N is a powerful workflow automation tool that allows you to connect different services and automate repetitive tasks through a visual interface. It's perfect for automating business processes, data synchronization, and API integrations.
Configure N8N
Set up N8N configuration and environment variables:
mkdir ~/.n8n
cd ~/.n8nnano ~/.bashrcAdd these environment variables to the end of the file:
export N8N_BASIC_AUTH_ACTIVE=true
export N8N_BASIC_AUTH_USER=your_username
export N8N_BASIC_AUTH_PASSWORD=your_secure_password
export N8N_HOST=0.0.0.0
export N8N_PORT=5678
export N8N_PROTOCOL=http
export NODE_ENV=productionsource ~/.bashrc🔐 Security: Replace "your_username" and "your_secure_password" with strong, unique credentials!
Set Up Nginx Reverse Proxy
Configure Nginx as a reverse proxy for N8N:
sudo apt install nginx -ysudo nano /etc/nginx/sites-available/n8nAdd the following Nginx configuration:
server {
listen 80;
server_name your-domain.com; # Replace with your domain
location / {
proxy_pass http://localhost:5678;
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;
proxy_read_timeout 86400;
}
}sudo ln -s /etc/nginx/sites-available/n8n /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginxSet Up SSL with Let's Encrypt
Secure your N8N installation with SSL certificate:
sudo apt install certbot python3-certbot-nginx -ysudo certbot --nginx -d your-domain.comsudo certbot renew --dry-run🔒 SSL Enabled: Your N8N instance is now secured with HTTPS!
Create Systemd Service
Set up N8N as a system service for automatic startup:
sudo nano /etc/systemd/system/n8n.serviceAdd the following service configuration:
[Unit]
Description=n8n workflow automation
After=network.target
[Service]
Type=simple
User=n8n
ExecStart=/usr/bin/n8n start
Restart=on-failure
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=n8n
Environment=NODE_ENV=production
Environment=N8N_BASIC_AUTH_ACTIVE=true
Environment=N8N_BASIC_AUTH_USER=your_username
Environment=N8N_BASIC_AUTH_PASSWORD=your_secure_password
Environment=N8N_HOST=0.0.0.0
Environment=N8N_PORT=5678
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable n8n
sudo systemctl start n8nsudo systemctl status n8nConfigure Firewall
Set up UFW firewall to secure your N8N installation:
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw enablesudo ufw status⚠️ Important: Make sure SSH is allowed before enabling UFW to avoid losing access to your server!
Database Setup (Optional)
For production use, consider switching from SQLite to PostgreSQL:
sudo apt install postgresql postgresql-contrib -ysudo -u postgres psql
CREATE DATABASE n8n;
CREATE USER n8nuser WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE n8n TO n8nuser;
\qexport DB_TYPE=postgresdb
export DB_POSTGRESDB_HOST=localhost
export DB_POSTGRESDB_PORT=5432
export DB_POSTGRESDB_DATABASE=n8n
export DB_POSTGRESDB_USER=n8nuser
export DB_POSTGRESDB_PASSWORD=secure_password📊 Database Tip: PostgreSQL provides better performance and reliability for production N8N deployments with high workflow volume.
Performance Tuning
Optimize N8N performance for your RamNode VPS:
Memory Optimization
export NODE_OPTIONS="--max-old-space-size=2048"N8N Production Settings
export N8N_LOG_LEVEL=warn
export N8N_METRICS=true
export EXECUTIONS_DATA_PRUNE=true
export EXECUTIONS_DATA_MAX_AGE=168 # Keep executions for 1 week
export N8N_ENCRYPTION_KEY="your-encryption-key"Performance Tips
- • Enable execution data pruning to manage database size
- • Use PostgreSQL for better performance with large datasets
- • Monitor memory usage and upgrade VPS if needed
- • Set appropriate log levels to reduce disk I/O
Backup Strategy
Implement automated backups for your N8N installation:
nano ~/backup-n8n.shAdd the following backup script:
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/home/n8n/backups"
mkdir -p $BACKUP_DIR
# Backup N8N data
tar -czf $BACKUP_DIR/n8n_backup_$DATE.tar.gz ~/.n8n/
# Backup database (if using PostgreSQL)
if [ "$DB_TYPE" = "postgresdb" ]; then
pg_dump -h localhost -U n8nuser n8n > $BACKUP_DIR/n8n_db_$DATE.sql
fi
# Keep only last 7 backups
find $BACKUP_DIR -name "n8n_backup_*.tar.gz" -mtime +7 -delete
find $BACKUP_DIR -name "n8n_db_*.sql" -mtime +7 -delete
echo "Backup completed: $DATE"chmod +x ~/backup-n8n.sh
crontab -e
# Add this line for daily backups at 2 AM
0 2 * * * /home/n8n/backup-n8n.shMonitoring and Logs
Set up monitoring to track N8N performance and health:
View N8N Logs
# View real-time logs
sudo journalctl -u n8n -f
# View recent logs
sudo journalctl -u n8n --no-pager
# View logs from last hour
sudo journalctl -u n8n --since "1 hour ago"System Resource Monitoring
# Check memory usage
free -h
# Check disk usage
df -h
# Check CPU usage
htop
# Check N8n process
ps aux | grep n8nLog Rotation Setup
sudo nano /etc/logrotate.d/n8n/var/log/n8n/*.log {
daily
rotate 7
compress
delaycompress
missingok
notifempty
create 644 n8n n8n
}Troubleshooting Common Issues
Common issues and their solutions when running N8N on RamNode:
🎉 Congratulations!
You've successfully deployed N8N workflow automation on your RamNode VPS! You can now automate tasks, connect services, and streamline your business processes.
