Deploy with cPanel
cPanel supports Node.js applications through its Application Manager. This guide covers deploying OpenCodeHub on cPanel-based shared hosting.
Prerequisites
Section titled “Prerequisites”- cPanel hosting with Node.js support (v18+)
- PostgreSQL database addon (or external database)
- SSH access recommended
- Domain configured in cPanel
Step 1: Create PostgreSQL Database
Section titled “Step 1: Create PostgreSQL Database”- Login to cPanel
- Go to Databases → PostgreSQL Databases
- Create a new database:
opencodehub - Create a new user with a strong password
- Add user to database with ALL PRIVILEGES
- Note the connection string:
postgresql://username:password@localhost:5432/opencodehub
Step 2: Upload Application Files
Section titled “Step 2: Upload Application Files”Option A: Git Clone (if SSH available)
Section titled “Option A: Git Clone (if SSH available)”ssh username@yourhost.comcd ~/git clone https://github.com/swadhinbiswas/OpencodeHub.git opencodehubOption B: File Manager Upload
Section titled “Option B: File Manager Upload”- Download the repository as ZIP from GitHub
- Go to cPanel → File Manager
- Navigate to your home directory
- Upload and extract the ZIP file
- Rename to
opencodehub
Step 3: Create Node.js Application
Section titled “Step 3: Create Node.js Application”- Go to cPanel → Setup Node.js App
- Click Create Application
- Configure:
| Setting | Value |
|---|---|
| Node.js version | 18.x or 20.x |
| Application mode | Production |
| Application root | opencodehub |
| Application URL | git.yourdomain.com |
| Application startup file | dist/server/entry.mjs |
- Click Create
Step 4: Configure Environment Variables
Section titled “Step 4: Configure Environment Variables”In the Node.js Application page:
- Scroll to Environment Variables
- Add the following:
NODE_ENV=productionPORT=3000SITE_URL=https://git.yourdomain.com
# DatabaseDATABASE_DRIVER=postgresDATABASE_URL=postgresql://cpuser_dbuser:password@localhost:5432/cpuser_opencodehub
# Security (generate with: openssl rand -hex 32)JWT_SECRET=<64-char-hex>SESSION_SECRET=<64-char-hex>INTERNAL_HOOK_SECRET=<64-char-hex>
# StorageSTORAGE_TYPE=localSTORAGE_PATH=./data/repos- Click Save
Step 5: Install Dependencies and Build
Section titled “Step 5: Install Dependencies and Build”- In the Node.js app page, click Run NPM Install
- Connect via SSH and run:
cd ~/opencodehub
# Enter virtual environmentsource /home/username/nodevenv/opencodehub/18/bin/activate
# Install dependenciesnpm install
# Build the applicationnpm run build
# Initialize databasenpm run db:push
# Create admin user (if script exists)npm run scripts/seed-admin.tsStep 6: Start Application
Section titled “Step 6: Start Application”- In cPanel Node.js app manager, click Start App
- Verify it’s running by visiting your domain
Alternative: Using PM2
Section titled “Alternative: Using PM2”If your host supports PM2:
# Install PM2 globallynpm install -g pm2
# Start with PM2pm2 start dist/server/entry.mjs --name opencodehub
# Save process listpm2 save
# Setup startup scriptpm2 startupHandling Git Operations
Section titled “Handling Git Operations”Important
cPanel’s Node.js apps may not handle long-running Git operations well. For push/pull with large repos, you may experience timeouts.
Workarounds
Section titled “Workarounds”- Increase PHP/Node timeout (if available in hosting settings)
- Use external storage (S3) to reduce local I/O
- Consider VPS for better control
Troubleshooting
Section titled “Troubleshooting”Application Won’t Start
Section titled “Application Won’t Start”- Check error logs in cPanel → Errors
- Verify Node.js version compatibility
- Check if all dependencies installed
- Verify startup file path is correct
Database Connection Errors
Section titled “Database Connection Errors”# Test connection via SSHpsql "postgresql://user:pass@localhost/dbname"503 Service Unavailable
Section titled “503 Service Unavailable”- Application may have crashed
- Check logs and restart via cPanel
Limitations Summary
Section titled “Limitations Summary”| Feature | cPanel Support |
|---|---|
| Web UI | ✅ Works |
| Git clone/push | ⚠️ May timeout on large repos |
| WebSockets | ❌ Usually not supported |
| Background jobs | ❌ Limited |
| Custom domains | ✅ Works |
| SSL | ✅ Via AutoSSL |
Recommended Alternative
Section titled “Recommended Alternative”For a Git server, we strongly recommend:
- VPS (DigitalOcean, Linode, Vultr) - Full control
- Docker on any cloud provider - Easy deployment
- Vercel/Cloudflare - For serverless approach
See Docker Deployment Guide for production setups.