AlisChain Debian Linux Installation Guide¶
System Requirements¶
- Debian 11+ or Ubuntu 20.04+
- 8GB RAM minimum (16GB recommended)
- 50GB free disk space
- Python 3.8+
- Node.js 16+
- Git
Installation Steps¶
1. Download and extract the AlisChain project to your desired location¶
2. Open terminal and navigate to the project directory:¶
cd path/to/alischain
3. Install System Dependencies¶
# Update package list
sudo apt update
sudo apt upgrade -y
# Install required packages
sudo apt install -y \
python3-pip \
python3-venv \
nodejs \
npm \
git \
redis-server \
nginx \
postgresql \
build-essential \
libpq-dev
4. Set Up Python Environment¶
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
5. Install Frontend Dependencies¶
cd frontend
npm install
6. Configure Environment¶
Create .env file:
cat > .env << EOL
ALISCHAIN_API_KEY=your_api_key
WEBSOCKET_URL=wss://api.alischain.com/ws
REDIS_URL=redis://localhost:6379
DATABASE_URL=postgresql://alischain:password@localhost/alischain
EOL
7. Set Up Database¶
# Create database and user
sudo -u postgres psql << EOF
CREATE DATABASE alischain;
CREATE USER alischain WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE alischain TO alischain;
EOF
# Run migrations
python manage.py migrate
8. Configure Nginx¶
Create Nginx configuration:
sudo tee /etc/nginx/sites-available/alischain << EOL
server {
listen 80;
server_name 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_cache_bypass \$http_upgrade;
}
}
EOL
# Enable site
sudo ln -s /etc/nginx/sites-available/alischain /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
9. Set Up Systemd Service¶
Create service file:
sudo tee /etc/systemd/system/alischain.service << EOL
[Unit]
Description=AlisChain Server
After=network.target
[Service]
User=alischain
Group=alischain
WorkingDirectory=/opt/alischain
Environment="PATH=/opt/alischain/venv/bin"
ExecStart=/opt/alischain/venv/bin/python server.py
Restart=always
[Install]
WantedBy=multi-user.target
EOL
# Start service
sudo systemctl enable alischain
sudo systemctl start alischain
Development Setup¶
1. Install Development Tools¶
# Install development dependencies
pip install -r requirements-dev.txt
# Install frontend development tools
npm install --save-dev @types/react @types/node
2. Configure Git¶
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Monitoring¶
System Monitoring¶
# Install monitoring tools
sudo apt install -y htop netdata prometheus node-exporter
# Start monitoring services
sudo systemctl enable netdata prometheus node-exporter
sudo systemctl start netdata prometheus node-exporter
Log Monitoring¶
# View logs
journalctl -u alischain -f
Backup and Recovery¶
Database Backup¶
# Create backup script
cat > backup.sh << EOL
#!/bin/bash
BACKUP_DIR="/var/backups/alischain"
TIMESTAMP=\$(date +%Y%m%d_%H%M%S)
mkdir -p \$BACKUP_DIR
# Backup database
pg_dump alischain > \$BACKUP_DIR/db_\$TIMESTAMP.sql
# Backup configuration
tar -czf \$BACKUP_DIR/config_\$TIMESTAMP.tar.gz /opt/alischain/.env
# Remove old backups (keep last 7 days)
find \$BACKUP_DIR -type f -mtime +7 -delete
EOL
chmod +x backup.sh
Security Hardening¶
1. Firewall Configuration¶
# Install and configure UFW
sudo apt install -y ufw
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow http
sudo ufw allow https
sudo ufw enable
2. SSL Configuration¶
# Install certbot
sudo apt install -y certbot python3-certbot-nginx
# Obtain SSL certificate
sudo certbot --nginx -d your_domain.com
3. Security Updates¶
# Configure automatic security updates
sudo apt install -y unattended-upgrades
sudo dpkg-reconfigure -plow unattended-upgrades
Performance Tuning¶
1. PostgreSQL Optimization¶
sudo tee -a /etc/postgresql/13/main/postgresql.conf << EOL
shared_buffers = 2GB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
work_mem = 32MB
max_worker_processes = 8
max_parallel_workers_per_gather = 4
EOL
2. Redis Configuration¶
sudo tee -a /etc/redis/redis.conf << EOL
maxmemory 2gb
maxmemory-policy allkeys-lru
EOL
Troubleshooting¶
Common Issues¶
Service Won't Start¶
# Check service status
sudo systemctl status alischain
# Check logs
journalctl -u alischain -n 100
Database Connection Issues¶
# Check PostgreSQL status
sudo systemctl status postgresql
# Check connection
psql -U alischain -h localhost -d alischain
Permission Issues¶
# Fix permissions
sudo chown -R alischain:alischain /opt/alischain
sudo chmod -R 755 /opt/alischain
Last update:
2024-12-08