CoAI LogoCoAI.Dev

Installation Guide

Comprehensive installation guide for CoAI.Dev across different environments and platforms

Installation Guide

This comprehensive guide covers installing CoAI.Dev across various environments, from simple development setups to enterprise production deployments. Choose the installation method that best fits your requirements and technical environment.

Overview

CoAI.Dev supports multiple installation methods:

  • 🐳 Docker: Containerized deployment for consistency and portability
  • πŸ”§ Docker Compose: Multi-container setup with dependencies
  • ☁️ Cloud Platforms: One-click deployment on cloud providers
  • πŸ–₯️ Traditional Server: Direct installation on Linux/Windows servers
  • ☸️ Kubernetes: Orchestrated deployment for high availability
  • πŸ“¦ Package Managers: Distribution-specific package installations

Quick Start

For the fastest setup, we recommend starting with Docker Compose or Zeabur One-Click Deployment which handle all dependencies automatically.

System Requirements

Minimum Requirements

Development/Testing Environment:

  • CPU: 2 cores, 2.0 GHz
  • Memory: 4GB RAM
  • Storage: 20GB available space
  • Network: Stable internet connection
  • OS: Linux, macOS, or Windows with Docker support

Production Environment:

  • CPU: 4+ cores, 2.5+ GHz
  • Memory: 8GB+ RAM (16GB+ for high traffic)
  • Storage: 100GB+ SSD storage
  • Network: High-speed internet with low latency
  • OS: Ubuntu 20.04+ LTS or CentOS 8+

Enterprise Requirements

High-Availability Environment:

  • CPU: 8+ cores per node, 3.0+ GHz
  • Memory: 32GB+ RAM per node
  • Storage: 500GB+ NVMe SSD with backup
  • Network: Redundant network connections
  • Infrastructure: Load balancers, monitoring, backup systems

Installation Methods

Docker Installation

Simple Docker Container Deployment

The fastest way to get CoAI.Dev running:

Install Docker

Ensure Docker is installed on your system:

# Ubuntu/Debian
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker $USER
 
# CentOS/RHEL
sudo yum install -y docker
sudo systemctl start docker
sudo systemctl enable docker
 
# macOS
# Install Docker Desktop from https://docker.com
# Windows
# Install Docker Desktop from https://docker.com

Run CoAI.Dev Container

Start CoAI.Dev with a single command:

# Basic setup with SQLite (development)
docker run -d \
  --name chatnio \
  -p 8000:8000 \
  -v chatnio_data:/data \
  programzmh/chatnio:latest
 
# With external database (production)
docker run -d \
  --name chatnio \
  -p 8000:8000 \
  -e MYSQL_HOST=your-mysql-host \
  -e MYSQL_USER=chatnio \
  -e MYSQL_PASSWORD=your-password \
  -e MYSQL_DB=chatnio \
  -e REDIS_HOST=your-redis-host \
  -e SECRET=your-jwt-secret \
  programzmh/chatnio:latest

Access Your Installation

Open your browser and navigate to:

Default Credentials:

  • Username: root
  • Password: chatnio123456

Security

Change the default password immediately after first login!

Manual Installation

Traditional Server Installation:

System Preparation

Prepare your server environment:

# Ubuntu/Debian
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget git build-essential
 
# CentOS/RHEL
sudo yum update -y
sudo yum groupinstall -y "Development Tools"
sudo yum install -y curl wget git
 
# Install Node.js (if using Node.js version)
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs
 
# Install Go (if using Go version)
wget https://go.dev/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

Database Setup

Install and configure database services:

MySQL Setup:

# Install MySQL
sudo apt install -y mysql-server
 
# Secure MySQL installation
sudo mysql_secure_installation
 
# Create database and user
sudo mysql -u root -p << EOF
CREATE DATABASE chatnio CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'chatnio'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON chatnio.* TO 'chatnio'@'localhost';
FLUSH PRIVILEGES;
EOF

Redis Setup:

# Install Redis
sudo apt install -y redis-server
 
# Configure Redis
sudo nano /etc/redis/redis.conf
# Uncomment and set: requirepass your_redis_password
 
# Restart Redis
sudo systemctl restart redis-server
sudo systemctl enable redis-server

Application Installation

Download and install CoAI.Dev:

# Create application directory
sudo mkdir -p /opt/chatnio
cd /opt/chatnio
 
# Download latest release
wget https://github.com/coaidev/coai/releases/latest/download/chatnio-linux-amd64.tar.gz
tar -xzf chatnio-linux-amd64.tar.gz
 
# Create configuration file
sudo nano config.yaml

Configuration File Example:

# config.yaml
server:
  host: "0.0.0.0"
  port: 8000
  secret: "your-jwt-secret-key"
 
database:
  host: "localhost"
  port: 3306
  user: "chatnio"
  password: "secure_password"
  name: "chatnio"
 
redis:
  host: "localhost"
  port: 6379
  password: "your_redis_password"
  db: 0
 
features:
  registration: true
  api: true
  search: true

Service Configuration

Set up CoAI.Dev as a system service:

# Create systemd service file
sudo nano /etc/systemd/system/chatnio.service

Service File:

[Unit]
Description=CoAI.Dev AI Platform
After=network.target mysql.service redis.service
Wants=mysql.service redis.service
 
[Service]
Type=simple
User=chatnio
Group=chatnio
WorkingDirectory=/opt/chatnio
ExecStart=/opt/chatnio/chatnio --config=/opt/chatnio/config.yaml
Restart=always
RestartSec=5
 
# Security settings
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/opt/chatnio/data /opt/chatnio/logs
 
[Install]
WantedBy=multi-user.target
# Create user and set permissions
sudo useradd --system --shell /bin/false chatnio
sudo chown -R chatnio:chatnio /opt/chatnio
 
# Enable and start service
sudo systemctl daemon-reload
sudo systemctl enable chatnio
sudo systemctl start chatnio
 
# Check status
sudo systemctl status chatnio

Reverse Proxy Setup

Nginx Configuration:

Install Nginx

# Ubuntu/Debian
sudo apt install -y nginx
 
# CentOS/RHEL
sudo yum install -y nginx
 
# Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx

Configure SSL Certificate

# Install Certbot
sudo apt install -y certbot python3-certbot-nginx
 
# Obtain SSL certificate
sudo certbot --nginx -d your-domain.com

Nginx Configuration

Create Nginx configuration:

# /etc/nginx/sites-available/chatnio
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;
 
    # Security headers
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
 
    # Upload size limit
    client_max_body_size 100M;
 
    location / {
        proxy_pass http://127.0.0.1:8000;
        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 300s;
        proxy_connect_timeout 75s;
    }
 
    # Static file caching
    location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
        proxy_pass http://127.0.0.1:8000;
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}
# Enable site
sudo ln -s /etc/nginx/sites-available/chatnio /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Post-Installation Setup

Initial Configuration

First Login

  1. Access Platform: Open https://your-domain.com in your browser
  2. Login: Use default credentials (root / chatnio123456)
  3. Change Password: Immediately change the default password
  4. Verify Installation: Check that all systems are functioning
# Verify services are running
sudo systemctl status chatnio
sudo systemctl status nginx
sudo systemctl status mysql
sudo systemctl status redis

Basic Configuration

Configure essential platform settings:

  1. Admin Panel: Navigate to Admin β†’ System Settings
  2. Site Information: Set site name, logo, and basic information
  3. Email Settings: Configure SMTP for notifications
  4. Security Settings: Enable content moderation and security features
  5. API Configuration: Set up API access if needed

Essential Settings Checklist:

  • Change default admin password
  • Configure site information
  • Set up SMTP email
  • Enable SSL/HTTPS
  • Configure backup procedures
  • Set up monitoring

Add AI Providers

Configure your first AI service channels:

  1. Channel Management: Go to Admin β†’ Channels
  2. Add Provider: Click "Add Channel"
  3. Configure API: Enter API keys and settings
  4. Test Connection: Verify channel connectivity
  5. Set Pricing: Configure billing and pricing

Popular Providers:

  • OpenAI (GPT models)
  • Anthropic (Claude models)
  • Google (Gemini models)
  • Azure OpenAI
  • Local models (Ollama, LocalAI)

Production Optimization

Performance Tuning:

# System optimization
echo 'vm.swappiness=10' | sudo tee -a /etc/sysctl.conf
echo 'net.core.rmem_max=16777216' | sudo tee -a /etc/sysctl.conf
echo 'net.core.wmem_max=16777216' | sudo tee -a /etc/sysctl.conf
 
# MySQL optimization
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
# Add:
# innodb_buffer_pool_size = 2G
# max_connections = 500
# query_cache_size = 256M
 
# Redis optimization
sudo nano /etc/redis/redis.conf
# Adjust:
# maxmemory 1gb
# maxmemory-policy allkeys-lru
 
# Restart services
sudo systemctl restart mysql redis chatnio nginx

Troubleshooting

Common Issues

Getting Help

If you encounter issues not covered here, check our troubleshooting guide or visit our GitHub repository for community support.

Service Won't Start:

# Check logs
sudo journalctl -u chatnio -f
sudo tail -f /opt/chatnio/logs/app.log
 
# Check configuration
sudo -u chatnio /opt/chatnio/chatnio --config=/opt/chatnio/config.yaml --check-config
 
# Verify dependencies
systemctl status mysql redis nginx

Database Connection Failed:

# Test MySQL connection
mysql -h localhost -u chatnio -p chatnio
 
# Check MySQL logs
sudo tail -f /var/log/mysql/error.log
 
# Verify user permissions
mysql -u root -p -e "SHOW GRANTS FOR 'chatnio'@'localhost';"

High Memory Usage:

# Monitor resource usage
htop
sudo systemctl status chatnio
 
# Optimize configuration
# Reduce worker processes, adjust cache sizes
# Consider adding swap if needed

Installation is complete! Continue with Quick Start Guide to configure your first AI channels and start using CoAI.Dev, or explore Deployment Options for more advanced deployment scenarios.