Installation Guide
Step-by-step guide for installing the SBM CRM Platform.
Prerequisites
System Requirements
- Operating System: Ubuntu 20.04 LTS or later, CentOS 8+, or macOS
- CPU: 4 cores minimum (8+ recommended for production)
- RAM: 8GB minimum (16GB+ recommended for production)
- Storage: 100GB minimum SSD storage
- Network: Stable internet connection for external API calls
Software Requirements
- Node.js: v18.0.0 or later
- Python: v3.9 or later (for AI services)
- PostgreSQL: v13 or later
- Redis: v6.0 or later
- Docker: v20.10 or later (optional, for containerized deployment)
- Docker Compose: v2.0 or later (optional)
Required Accounts
- WeChat Official Account credentials
- WeChat Mini Program credentials
- Domain name and SSL certificate
- Email service credentials (for notifications)
Installation Methods
Method 1: Docker Compose (Recommended)
The easiest way to get started is using Docker Compose.
Step 1: Clone Repository
git clone https://github.com/your-org/sbm-crm-platform.git
cd sbm-crm-platform
Step 2: Configure Environment
cp .env.example .env
# Edit .env with your configuration
nano .env
Step 3: Start Services
docker-compose up -d
Step 4: Run Migrations
docker-compose exec api npm run migrate
Step 5: Seed Initial Data
docker-compose exec api npm run seed
Method 2: Manual Installation
Step 1: Install Dependencies
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install PostgreSQL
sudo apt-get install -y postgresql postgresql-contrib
# Install Redis
sudo apt-get install -y redis-server
# Install Python and dependencies
sudo apt-get install -y python3 python3-pip
Step 2: Set Up Database
# Create database user
sudo -u postgres createuser -s sbmcrm
# Create database
sudo -u postgres createdb sbmcrm_production
# Set password
sudo -u postgres psql -c "ALTER USER sbmcrm WITH PASSWORD 'your_secure_password';"
Step 3: Install Application
# Clone repository
git clone https://github.com/your-org/sbm-crm-platform.git
cd sbm-crm-platform
# Install Node.js dependencies
npm install
# Install Python dependencies
cd ai-services
pip3 install -r requirements.txt
cd ..
Step 4: Configure Application
# Copy configuration template
cp config/config.example.json config/config.production.json
# Edit configuration
nano config/config.production.json
Step 5: Run Database Migrations
npm run migrate:production
Step 6: Start Services
# Start API server
npm run start:production
# Start AI services (in separate terminal)
cd ai-services
python3 app.py
Verification
Check API Health
curl http://localhost:3000/health
Expected response:
{
"status": "healthy",
"version": "1.0.0",
"database": "connected",
"redis": "connected"
}
Check Services
# Check PostgreSQL
sudo systemctl status postgresql
# Check Redis
sudo systemctl status redis
# Check application logs
tail -f logs/app.log
Next Steps
- Configure SSL/TLS certificates (see SSL/TLS Setup)
- Set up database backups (see Backup & Recovery)
- Configure monitoring (see Monitoring)
- Review production configuration (see Configuration)
Troubleshooting
Port Already in Use
If port 3000 is already in use:
# Find process using port
lsof -i :3000
# Kill process or change port in config
Database Connection Failed
Check PostgreSQL is running and credentials are correct:
# Test connection
psql -U sbmcrm -d sbmcrm_production -h localhost
# Check PostgreSQL logs
sudo tail -f /var/log/postgresql/postgresql-*.log
Redis Connection Failed
Check Redis is running:
# Test connection
redis-cli ping
# Check Redis logs
sudo tail -f /var/log/redis/redis-server.log
Uninstallation
Docker Compose
docker-compose down -v
Manual Installation
# Stop services
sudo systemctl stop sbmcrm-api
sudo systemctl stop sbmcrm-ai
# Remove application files
rm -rf /opt/sbmcrm
# Remove database (WARNING: This deletes all data)
sudo -u postgres dropdb sbmcrm_production