Linux Server Setup Guide

Complete installation and configuration guide for running ContentWing on Linux servers. Includes Docker and native installation methods with security best practices.

System Requirements

Ensure your Linux server meets these requirements before installation:

ComponentMinimumRecommendedNotes
Operating SystemUbuntu 18.04+ / CentOS 7+ / Debian 9+Ubuntu 20.04 LTS / CentOS 8+ / Debian 11Any modern Linux distribution with systemd support
CPU2 cores, 2.0 GHz4+ cores, 2.5+ GHzARM64 and x86_64 architectures supported
Memory (RAM)4 GB8+ GBMore RAM improves AI processing performance
Storage20 GB free space50+ GB SSDSSD recommended for database performance
NetworkStable internet connection100+ Mbps bandwidthRequired for social media API communications

Choose Installation Method

Select the installation method that best fits your needs and expertise:

Docker (Recommended)

Easy

Quick setup using Docker containers

Setup time: 15 minutes

Pros:

  • Isolated environment
  • Easy updates
  • Consistent across systems
  • Built-in dependency management

Cons:

  • Requires Docker knowledge
  • Slightly higher resource usage

Native Installation

Moderate

Direct installation on Linux system

Setup time: 30-45 minutes

Pros:

  • Better performance
  • Full system control
  • Lower resource overhead
  • Custom configurations

Cons:

  • Manual dependency management
  • System-specific issues
  • More complex updates

Docker Installation (Recommended)

Follow these steps for a quick Docker-based installation:

1

Install Docker & Docker Compose

Terminal
# Update package index
sudo apt update

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Add user to docker group
sudo usermod -aG docker $USER

# Install Docker Compose
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
2

Download ContentWing

Terminal
# Create application directory
mkdir -p ~/contentwing && cd ~/contentwing

# Download docker-compose.yml
curl -O https://releases.contentwing.com/latest/docker-compose.yml

# Download environment template
curl -O https://releases.contentwing.com/latest/.env.example
cp .env.example .env
3

Configure Environment

Terminal
# Edit environment file
nano .env

# Required settings:
# APP_URL=https://your-domain.com
# DATABASE_URL=postgresql://user:pass@db:5432/contentwing
# JWT_SECRET=your-super-secret-key
# REDIS_URL=redis://redis:6379
4

Start Services

Terminal
# Start all services
docker-compose up -d

# Check service status
docker-compose ps

# View logs
docker-compose logs -f app

Native Installation

For advanced users who prefer direct system installation:

1

Install Dependencies

Terminal
# Update system packages
sudo apt update && sudo apt upgrade -y

# Install Node.js 18+
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

# Install PostgreSQL
sudo apt install postgresql postgresql-contrib -y

# Install Redis
sudo apt install redis-server -y

# Install Nginx (optional, for reverse proxy)
sudo apt install nginx -y
2

Setup Database

Terminal
# Switch to postgres user
sudo -u postgres psql

# Create database and user (in PostgreSQL shell)
CREATE DATABASE contentwing;
CREATE USER contentwing_user WITH PASSWORD 'secure_password';
GRANT ALL PRIVILEGES ON DATABASE contentwing TO contentwing_user;
\q

# Test connection
psql -h localhost -U contentwing_user -d contentwing
3

Install ContentWing

Terminal
# Create application directory
sudo mkdir -p /opt/contentwing
sudo chown $USER:$USER /opt/contentwing
cd /opt/contentwing

# Download latest release
curl -L https://releases.contentwing.com/latest/contentwing-linux.tar.gz | tar xz

# Install dependencies
npm install --production

# Copy configuration template
cp .env.example .env
4

Configure & Start

Terminal
# Edit configuration
nano .env

# Run database migrations
npm run db:migrate

# Create systemd service
sudo cp contentwing.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable contentwing
sudo systemctl start contentwing

Security Configuration

Secure your ContentWing installation with these essential security measures:

Firewall Configuration

Enable UFW firewall: sudo ufw enable
Allow SSH: sudo ufw allow 22/tcp
Allow HTTP: sudo ufw allow 80/tcp
Allow HTTPS: sudo ufw allow 443/tcp
Block unnecessary ports: sudo ufw default deny incoming

SSL Certificate

Install Certbot: sudo apt install certbot python3-certbot-nginx
Obtain certificate: sudo certbot --nginx -d your-domain.com
Test auto-renewal: sudo certbot renew --dry-run
Setup auto-renewal cron job
Verify HTTPS is working

System Hardening

Disable root login: sudo nano /etc/ssh/sshd_config
Use SSH keys instead of passwords
Keep system updated: sudo unattended-upgrades
Setup fail2ban: sudo apt install fail2ban
Configure log monitoring

Nginx Reverse Proxy

Configure Nginx as a reverse proxy for better performance and SSL termination:

Nginx Configuration

server {
    listen 80;
    server_name your-domain.com;
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl http2;
    server_name your-domain.com;

    ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;

    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;
    }
}

Setup Instructions:

1. Save this config to /etc/nginx/sites-available/contentwing

2. Create symlink: sudo ln -s /etc/nginx/sites-available/contentwing /etc/nginx/sites-enabled/

3. Test config: sudo nginx -t

4. Reload Nginx: sudo systemctl reload nginx

Monitoring & Maintenance

Keep your ContentWing installation healthy with these monitoring tools:

System Monitoring

Monitor server resources and performance

Terminal
# Install htop for process monitoring
sudo apt install htop

# Install iotop for disk I/O monitoring
sudo apt install iotop

# Monitor ContentWing logs
sudo journalctl -u contentwing -f

Database Monitoring

Monitor PostgreSQL performance

Terminal
# Check database connections
sudo -u postgres psql -c "SELECT * FROM pg_stat_activity;"

# Monitor database size
sudo -u postgres psql -c "SELECT pg_size_pretty(pg_database_size('contentwing'));"

# Check slow queries
sudo nano /etc/postgresql/*/main/postgresql.conf

Common Management Commands

Docker Commands

docker-compose up -d - Start services
docker-compose down - Stop services
docker-compose logs -f - View logs
docker-compose pull && docker-compose up -d - Update

System Commands

sudo systemctl status contentwing - Check status
sudo systemctl restart contentwing - Restart service
sudo journalctl -u contentwing -f - View logs
cd /opt/contentwing && npm update - Update app

Common Issues & Solutions

Port 3000 Already in Use

Another service is using port 3000.

sudo lsof -i :3000 - Find process using port
sudo kill -9 PID - Kill process by PID

Database Connection Failed

Cannot connect to PostgreSQL database.

sudo systemctl status postgresql - Check PostgreSQL status
sudo systemctl start postgresql - Start PostgreSQL
sudo -u postgres psql -c "SELECT version();" - Test connection

SSL Certificate Issues

HTTPS not working or certificate expired.

sudo certbot renew - Renew certificates
sudo nginx -t - Test Nginx configuration
sudo systemctl reload nginx - Reload Nginx

Next Steps

Your Linux server is now ready! Continue with these guides:

Server Setup Complete!

Your ContentWing server is now running on Linux. Start creating amazing content!