This guide covers the complete process of building and deploying SimpleCMS in a production environment.
-
Install production dependencies:
cd backend pip install -r requirements.txt pip install gunicorn # For production WSGI server
-
Collect static files:
python manage.py collectstatic --noinput
-
Run database migrations:
python manage.py migrate
-
Build web application:
cd frontend npm install npm run build -
Build Electron application (optional):
cd electron npm install npm run build:linux # or build:win, build:mac
- Ubuntu 20.04+ or CentOS 7+
- Python 3.8+
- Node.js 20.19.0+
- Nginx
- Systemd
-
Create application directory:
sudo mkdir -p /opt/SimpleCms sudo chown $USER:nginx /opt/SimpleCms -
Deploy application files:
# Copy your application to /opt/SimpleCms/ cp -r backend/ /opt/SimpleCms/ cp -r frontend/dist/ /opt/SimpleCms/frontend/ -
Set up Python virtual environment:
cd /opt/SimpleCms/backend python3 -m venv /opt/venv source /opt/venv/bin/activate pip install -r requirements.txt pip install gunicorn
-
Configure Django settings:
# Update settings.py for production DEBUG = False ALLOWED_HOSTS = ['your-domain.com', '192.168.1.100'] STATIC_ROOT = '/opt/SimpleCms/backend/static/'
-
Collect static files:
python manage.py collectstatic --noinput
-
Copy service file:
sudo cp deployment/simplecms.service.sample /etc/systemd/system/simplecms.service
-
Edit service file (update paths as needed):
sudo nano /etc/systemd/system/simplecms.service
-
Enable and start service:
sudo systemctl daemon-reload sudo systemctl enable simplecms sudo systemctl start simplecms sudo systemctl status simplecms
-
Copy nginx configuration:
sudo cp deployment/nginx_simplecms.conf.sample /etc/nginx/sites-available/simplecms
-
Edit configuration (update server_name and paths):
sudo nano /etc/nginx/sites-available/simplecms
-
Enable site and restart nginx:
sudo ln -s /etc/nginx/sites-available/simplecms /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
Start/Stop/Restart SimpleCMS:
sudo systemctl start simplecms
sudo systemctl stop simplecms
sudo systemctl restart simplecmsView logs:
sudo journalctl -u simplecms -fCheck service status:
sudo systemctl status simplecms- Backend API:
http://your-domain.com:8001 - Frontend Web App:
http://your-domain.com:8002 - Admin Interface:
http://your-domain.com:8001/admin/
-
Firewall configuration:
sudo ufw allow 8001 sudo ufw allow 8002
-
SSL/TLS setup (recommended):
- Use Let's Encrypt for free SSL certificates
- Update nginx configuration to redirect HTTP to HTTPS
-
File permissions:
sudo chown -R root:nginx /opt/SimpleCms/ sudo chmod -R 755 /opt/SimpleCms/ sudo chmod 660 /opt/SimpleCms/backend/db.sqlite3 # if using SQLite
Log rotation (add to /etc/logrotate.d/simplecms):
/var/log/simplecms/*.log {
daily
missingok
rotate 52
compress
delaycompress
notifempty
create 644 root root
}
Backup database:
# For SQLite
cp /opt/SimpleCms/backend/db.sqlite3 /backup/db-$(date +%Y%m%d).sqlite3
# For PostgreSQL/MySQL - use appropriate dump commands-
Service fails to start:
- Check logs:
sudo journalctl -u simplecms -f - Verify file permissions and paths
- Ensure virtual environment is activated
- Check logs:
-
Nginx 502 Bad Gateway:
- Check if gunicorn is running:
sudo systemctl status simplecms - Verify socket file exists:
ls -la /run/simplecms.sock - Check nginx error logs:
sudo tail -f /var/log/nginx/error.log
- Check if gunicorn is running:
-
Static files not loading:
- Run
python manage.py collectstatic --noinput - Check nginx configuration for static file serving
- Verify STATIC_ROOT setting in Django
- Run
-
Database connection issues:
- Check database file permissions
- Verify database configuration in settings.py
- Run migrations:
python manage.py migrate
-
Gunicorn workers:
- Adjust worker count in service file based on CPU cores
- Monitor memory usage and adjust accordingly
-
Nginx caching:
- Add caching headers for static files
- Consider using nginx caching for API responses
-
Database optimization:
- Regular database maintenance
- Consider using PostgreSQL for better performance
- Monitor database query performance