AlisChain Fedora Linux Installation Guide¶
System Requirements¶
- Fedora 35+
- 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 dnf update -y
# Install required packages
sudo dnf install -y \
python3-pip \
python3-devel \
nodejs \
npm \
git \
redis \
nginx \
postgresql \
postgresql-server \
postgresql-devel \
gcc \
gcc-c++ \
make
2. Initialize PostgreSQL¶
# Initialize database
sudo postgresql-setup --initdb
# 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
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 SELinux¶
# Allow network connections
sudo setsebool -P httpd_can_network_connect 1
# Set correct context for application
sudo semanage fcontext -a -t httpd_sys_content_t "/opt/alischain(/.*?)?"
sudo restorecon -Rv /opt/alischain
7. 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
8. 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
9. Configure Nginx¶
Create nginx configuration:
sudo tee /etc/nginx/conf.d/alischain.conf << 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
# Test and restart nginx
sudo nginx -t
sudo systemctl restart nginx
10. 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¶
# Configure firewall
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
2. SSL Configuration¶
# Install certbot
sudo dnf install -y certbot python3-certbot-nginx
# Obtain SSL certificate
sudo certbot --nginx -d your_domain.com
Monitoring¶
System Monitoring¶
# Install monitoring tools
sudo dnf install -y \
prometheus \
prometheus-node-exporter \
grafana
# Start monitoring services
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl enable node_exporter
sudo systemctl start node_exporter
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
Log Monitoring¶
# View logs
journalctl -u alischain -f
Performance Tuning¶
PostgreSQL Optimization¶
sudo tee -a /var/lib/pgsql/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.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¶
SELinux Issues¶
# Check SELinux status
sestatus
# View SELinux logs
sudo ausearch -m AVC -ts recent
# Set permissive mode for testing
sudo setenforce 0
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
Last update:
2024-12-08