AlisChain Arch Linux Installation Guide¶
System Requirements¶
- Arch Linux (latest)
- 8GB RAM minimum (16GB recommended)
- 50GB free disk space
- Python 3.8+
- Node.js 16+
- Git
Installation Steps¶
1. Install System Dependencies¶
# Update system
sudo pacman -Syu
# Install required packages
sudo pacman -S \
python \
python-pip \
nodejs \
npm \
git \
redis \
nginx \
postgresql \
base-devel
# Install AUR helper (yay)
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
cd ..
rm -rf yay
2. Initialize PostgreSQL¶
# Initialize database
sudo -u postgres initdb -D /var/lib/postgres/data
# Start and enable services
sudo systemctl enable postgresql
sudo systemctl start postgresql
sudo systemctl enable redis
sudo systemctl start redis
3. Clone Repository¶
# Create project directory
sudo mkdir -p /opt/alischain
sudo chown -R $USER:$USER /opt/alischain
cd /opt/alischain
# Clone repository
git clone https://github.com/alischain/alischain.git .
4. Set Up Python Environment¶
# Create virtual environment
python -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¶
# Switch to postgres user
sudo -u postgres psql
# Create database and user
CREATE DATABASE alischain;
CREATE USER alischain WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE alischain TO alischain;
\q
# 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
# Create sites-enabled directory if it doesn't exist
sudo mkdir -p /etc/nginx/sites-enabled
# Create symlink
sudo ln -s /etc/nginx/sites-available/alischain /etc/nginx/sites-enabled/
# Test and restart nginx
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
# Create system user
sudo useradd -r -s /bin/false alischain
# Set permissions
sudo chown -R alischain:alischain /opt/alischain
# 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"
Security¶
1. Firewall Configuration¶
# Install and configure ufw
sudo pacman -S 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 pacman -S certbot certbot-nginx
# Obtain SSL certificate
sudo certbot --nginx -d your_domain.com
Monitoring¶
System Monitoring¶
# Install monitoring tools
sudo pacman -S prometheus prometheus-node-exporter grafana
# Start monitoring services
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl enable prometheus-node-exporter
sudo systemctl start prometheus-node-exporter
sudo systemctl enable grafana
sudo systemctl start grafana
Log Monitoring¶
# View logs
journalctl -u alischain -f
Performance Tuning¶
PostgreSQL Optimization¶
sudo tee -a /var/lib/postgres/data/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
sudo systemctl restart postgresql
Redis Configuration¶
sudo tee -a /etc/redis/redis.conf << EOL
maxmemory 2gb
maxmemory-policy allkeys-lru
EOL
sudo systemctl restart redis
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
Troubleshooting¶
Common Issues¶
Package Conflicts¶
# Check for package conflicts
pacman -Qk
# Fix package dependencies
sudo pacman -Syu --overwrite "*"
Service Issues¶
# Check service status
sudo systemctl status alischain
# View 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