Prerequisites
Before starting the migration, ensure you have:
Server Requirements
- • RamNode VPS (Ubuntu 24.04 LTS+)
- • SSH access (root/sudo privileges)
- • Basic Linux command line knowledge
- • Domain name (optional)
Application Requirements
- • Replit application ready for deployment
- • Application dependencies documented
- • Access to source code
- • Environment variables list
Preparing Your RamNode VPS
Set up your RamNode VPS environment for hosting your Replit application:
ssh root@your-server-ipapt update && apt upgrade -yapt install -y curl wget git unzip software-properties-common apt-transport-https ca-certificates gnupg lsb-releaseadduser appuser
usermod -aG sudo appuser
su - appuser💡 Security: Using a non-root user for application deployment follows security best practices.
Install Required Runtime Environment
Install the appropriate runtime based on your Replit application's technology stack:
For Node.js Applications:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejsnode --version
npm --versionFor Python Applications:
sudo apt install -y python3 python3-pip python3-venv python3-dev
python3 --version
pip3 --versionFor Java Applications:
sudo apt install -y openjdk-17-jdk
java --version
javac --versionFor C++ Applications:
sudo apt install -y build-essential gcc g++ make
gcc --versionFor Go Applications:
wget https://golang.org/dl/go1.21.0.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.21.0.linux-amd64.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
source ~/.bashrc
go version✅ Runtime environment is now installed and ready for your application.
Migrate Your Application
Transfer your Replit application code to your VPS:
Method 1: Git Clone (Recommended):
cd /home/appuser
git clone https://github.com/your-username/your-replit-app.git
cd your-replit-appMethod 2: Download from Replit:
wget https://replit.com/@your-username/your-project/archive/main.zip
unzip main.zip
cd your-project-mainMethod 3: SCP Upload:
scp -r /path/to/your/replit-app appuser@your-server-ip:/home/appuser/Install Dependencies:
Node.js:
npm installPython:
pip3 install -r requirements.txtBuild Application (if needed):
# For Node.js applications
npm run build
# For Java applications
javac *.java
# For Go applications
go build💡 Note: Ensure all dependencies from your Replit environment are included in your project files.
Database Setup
Set up databases if your Replit application uses them:
PostgreSQL Setup:
sudo apt install -y postgresql postgresql-contrib
sudo systemctl start postgresql
sudo systemctl enable postgresqlsudo -u postgres psql
CREATE DATABASE your_app_db;
CREATE USER your_app_user WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE your_app_db TO your_app_user;
\qMySQL/MariaDB Setup:
sudo apt install -y mysql-server
sudo systemctl start mysql
sudo systemctl enable mysql
sudo mysql_secure_installationsudo mysql
CREATE DATABASE your_app_db;
CREATE USER 'your_app_user'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON your_app_db.* TO 'your_app_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;MongoDB Setup:
wget -qO - https://www.mongodb.org/static/pgp/server-7.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list
sudo apt update
sudo apt install -y mongodb-org
sudo systemctl start mongod
sudo systemctl enable mongodRedis Setup (for caching):
sudo apt install -y redis-server
sudo systemctl start redis-server
sudo systemctl enable redis-server
redis-cli ping💡 Migration: Export your data from Replit's database and import it into your VPS database using appropriate tools.
Process Management Setup
Set up process management to keep your application running:
For Node.js - Install PM2:
sudo npm install -g pm2nano ecosystem.config.jsmodule.exports = {
apps: [{
name: 'replit-app',
script: './main.js', // or your main file
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'production',
PORT: 3000
}
}]
};pm2 start ecosystem.config.js
pm2 save
pm2 startupFor Python - Create Systemd Service:
sudo nano /etc/systemd/system/replit-app.service[Unit]
Description=Replit Python Application
After=network.target
[Service]
Type=simple
User=appuser
WorkingDirectory=/home/appuser/your-replit-app
Environment=PATH=/home/appuser/your-replit-app/venv/bin
ExecStart=/home/appuser/your-replit-app/venv/bin/python main.py
Restart=always
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable replit-app
sudo systemctl start replit-appFor Java Applications:
sudo nano /etc/systemd/system/replit-java-app.service[Unit]
Description=Replit Java Application
After=network.target
[Service]
Type=simple
User=appuser
WorkingDirectory=/home/appuser/your-replit-app
ExecStart=/usr/bin/java -jar your-app.jar
Restart=always
[Install]
WantedBy=multi-user.target🚀 Success: Your application will now automatically restart if it crashes and start on system boot.
Nginx Configuration
Configure Nginx as a reverse proxy for your application:
Install Nginx:
sudo apt install -y nginx
sudo systemctl start nginx
sudo systemctl enable nginxCreate Site Configuration:
sudo nano /etc/nginx/sites-available/replit-appserver {
listen 80;
server_name your-domain.com www.your-domain.com;
location / {
proxy_pass http://localhost:3000; # Adjust port as needed
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;
}
# Handle static files
location /static/ {
alias /home/appuser/your-replit-app/static/;
expires 30d;
add_header Cache-Control "public, no-transform";
}
# 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 Site:
sudo ln -s /etc/nginx/sites-available/replit-app /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx💡 Port Configuration: Make sure the proxy_pass port matches the port your Replit application runs on.
SSL Certificate Setup
Secure your application with SSL certificates:
Install Certbot:
sudo apt install -y snapd
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-runConfigure Firewall:
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw enable🔒 Secured: Your application is now accessible via HTTPS with automatic certificate renewal.
Environment Configuration
Configure environment variables and application settings:
Create Environment File:
nano /home/appuser/your-replit-app/.env# Application Settings
NODE_ENV=production
PORT=3000
HOST=0.0.0.0
# Database Configuration
DATABASE_URL=postgresql://user:password@localhost:5432/your_app_db
REDIS_URL=redis://localhost:6379
# API Keys and Secrets
API_KEY=your_api_key
SECRET_KEY=your_secret_key
# Replit-specific variables
REPL_ID=your_repl_id
REPL_SLUG=your_repl_slugSecure Environment File:
chmod 600 .env
chown appuser:appuser .envLoad Environment in Application:
For Node.js applications, ensure you load environment variables:
// At the top of your main.js file
require('dotenv').config();
// Or for ES modules
import 'dotenv/config';Update Process Manager Configuration:
module.exports = {
apps: [{
name: 'replit-app',
script: './main.js',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env_file: '.env', // Load environment file
env: {
NODE_ENV: 'production'
}
}]
};🔐 Security: Never commit .env files to version control. Keep sensitive data secure and use different values for production.
Monitoring and Logging
Set up monitoring and logging for your migrated application:
Application Monitoring:
- • Monitor application performance
- • Track memory and CPU usage
- • Monitor response times
- • Set up error tracking
Server Monitoring:
- • Monitor disk space usage
- • Track server resources
- • Monitor database performance
- • Set up uptime monitoring
Essential Monitoring Commands:
# Check system resources
htop
# Check disk usage
df -h
# Monitor PM2 applications (Node.js)
pm2 status
pm2 logs replit-app
pm2 monit
# Check systemd services (Python/Java)
sudo systemctl status replit-app
sudo journalctl -u replit-app -f
# Monitor Nginx
sudo tail -f /var/log/nginx/access.log
sudo tail -f /var/log/nginx/error.log
# Check database status
sudo systemctl status postgresql
sudo systemctl status mysql
sudo systemctl status mongodSet Up Log Rotation:
# For PM2 logs
pm2 install pm2-logrotate
pm2 set pm2-logrotate:max_size 10M
pm2 set pm2-logrotate:retain 30
# For custom application logs
sudo nano /etc/logrotate.d/replit-appTroubleshooting Common Migration Issues
🎉 Migration Complete!
Congratulations! You've successfully migrated your Replit application to your RamNode VPS. Your application now has greater control, better performance, and more deployment flexibility compared to the hosted Replit environment.
