-
Server Requirements:
- Ubuntu 20.04+ or similar Linux distribution
- Node.js 18+ and npm
- PostgreSQL 12+
- At least 1GB RAM
- Domain name (optional but recommended)
-
Local Requirements:
- Git installed on your local machine
- SSH access to your server
# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js 20
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Verify installation
node --version
npm --version# Install PostgreSQL
sudo apt install postgresql postgresql-contrib -y
# Start and enable PostgreSQL
sudo systemctl start postgresql
sudo systemctl enable postgresql
# Create database and user
sudo -u postgres psqlIn PostgreSQL shell:
CREATE DATABASE graceteam;
CREATE USER graceuser WITH ENCRYPTED PASSWORD 'your_secure_password';
GRANT ALL PRIVILEGES ON DATABASE graceteam TO graceuser;
\qsudo npm install -g pm2# Clone your repository (or upload files)
git clone <your-repo-url> graceteam
cd graceteam
# Install dependencies
npm install
# Build the application
npm run buildCreate a .env file:
nano .envAdd these variables:
NODE_ENV=production
PORT=5000
DATABASE_URL=postgresql://graceuser:your_secure_password@localhost/graceteam
SESSION_SECRET=your_very_long_random_session_secret
SENDGRID_API_KEY=your_sendgrid_api_key_if_you_have_one# Push database schema
npm run db:pushCreate ecosystem.config.js:
module.exports = {
apps: [{
name: 'graceteam',
script: 'server/index.ts',
interpreter: 'npx',
interpreter_args: 'tsx',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '1G',
env: {
NODE_ENV: 'production',
PORT: 5000
}
}]
};# Start the application
pm2 start ecosystem.config.js
# Save PM2 configuration
pm2 save
# Setup PM2 to start on boot
pm2 startup
# Follow the command it providessudo apt install nginx -ysudo nano /etc/nginx/sites-available/graceteamAdd this configuration:
server {
listen 80;
server_name your-domain.com www.your-domain.com;
location / {
proxy_pass http://localhost:5000;
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;
}
}# Enable the site
sudo ln -s /etc/nginx/sites-available/graceteam /etc/nginx/sites-enabled/
# Test nginx configuration
sudo nginx -t
# Restart nginx
sudo systemctl restart nginxsudo apt install certbot python3-certbot-nginx -ysudo certbot --nginx -d your-domain.com -d www.your-domain.com# Allow SSH, HTTP, and HTTPS
sudo ufw allow ssh
sudo ufw allow 'Nginx Full'
sudo ufw enable# Check PM2 status
pm2 status
# View logs
pm2 logs graceteam
# Restart if needed
pm2 restart graceteamCreate backup.sh:
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
pg_dump -U graceuser -h localhost graceteam > /home/backup/graceteam_$DATE.sql
# Keep only last 7 days of backups
find /home/backup -name "graceteam_*.sql" -mtime +7 -deleteMake it executable and add to cron:
chmod +x backup.sh
crontab -e
# Add: 0 2 * * * /path/to/backup.sh-
Port already in use:
sudo lsof -i :5000 sudo kill -9 <PID>
-
Database connection issues:
- Check PostgreSQL is running:
sudo systemctl status postgresql - Verify credentials in .env file
- Check database exists:
sudo -u postgres psql -l
- Check PostgreSQL is running:
-
Permission issues:
sudo chown -R $USER:$USER /path/to/graceteam
-
Application not starting:
pm2 logs graceteam
- Change default passwords
- Keep system updated:
sudo apt update && sudo apt upgrade - Use strong session secrets
- Regular backups
- Monitor logs:
pm2 logs - Use fail2ban:
sudo apt install fail2ban
To update the application:
# Pull latest changes
git pull origin main
# Install any new dependencies
npm install
# Restart application
pm2 restart graceteamYour application will be accessible at:
- HTTP:
http://your-domain.comorhttp://your-server-ip - HTTPS:
https://your-domain.com(if SSL configured)
The super admin login will be available at /login with automatic privileges as configured in your application.