12 - Ubuntu Server Installation
Overview
This guide covers deploying OpenAlgo on an Ubuntu server (22.04 or 24.04 LTS) with an Nginx reverse proxy, a systemd service, and SSL for production use. pyproject.toml sets requires-python = ">=3.12", so Python 3.12 or newer is mandatory. The steps below are the manual equivalent of install/install.sh, which automates the same work and additionally offers Remote MCP setup.
Architecture Diagram
┌──────────────────────────────────────────────────────────────────────────────┐
│ Ubuntu Server Architecture │
└──────────────────────────────────────────────────────────────────────────────┘
Internet
│
▼
┌──────────────────────────────────────────────────────────────────────────────┐
│ Nginx (Reverse Proxy) │
│ Port 80/443 │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ - SSL termination (Let's Encrypt) │ │
│ │ - HTTP → HTTPS redirect │ │
│ │ - WebSocket upgrade support │ │
│ │ - Static file serving │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────────────┐
│ OpenAlgo (Gunicorn + WebSocket) │
│ │
│ Flask App ─────────── localhost:5000 │
│ WebSocket Thread ──── localhost:8765 │
│ │
│ systemd: openalgo │
└─────────────────────────────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────────────────────────────┐
│ File System │
│ │
│ /opt/openalgo/ │
│ ├── .venv/ # Virtual environment │
│ ├── db/ # SQLite databases │
│ ├── log/ # Application logs │
│ ├── strategies/ # User strategies │
│ ├── .env # Configuration │
│ └── app.py # Main application │
└──────────────────────────────────────────────────────────────────────────────┘Prerequisites
Installation Steps
1. Clone Repository
2. Setup Python Environment
3. Configure Environment
4. Build Frontend
5. Create Systemd Service
Note: One systemd service is sufficient. Under Gunicorn/eventlet, websocket_proxy.app_integration spawns the WebSocket proxy as an isolated child process on port 8765; it is not an in-process daemon thread.
Important: Use -w 1 (single worker) for WebSocket compatibility.
The bundled install/install.sh binds gunicorn to a unix socket under /run instead of 127.0.0.1:5000 and points the Nginx upstream at that socket. Either binding works; keep the systemd unit and the Nginx proxy_pass consistent with whichever you choose.
6. Set Permissions
7. Configure Nginx
8. Enable Service
9. Setup SSL (Let's Encrypt)
Service Management
Firewall Configuration
Update Procedure
Troubleshooting
502 Bad Gateway
Check if OpenAlgo service is running: systemctl status openalgo
WebSocket fails
Check Nginx /ws proxy config and service logs
Permission denied
Verify www-data ownership: chown -R www-data:www-data /opt/openalgo
SSL error
Renew certificates: sudo certbot renew
Key Files Reference
/etc/systemd/system/openalgo.service
Main service (includes WebSocket)
/etc/nginx/sites-available/openalgo
Nginx config
/opt/openalgo/.env
Application config
/var/log/nginx/
Nginx logs
Note: There is no separate openalgo-ws.service. The Gunicorn-managed application starts the WebSocket proxy as a child process on port 8765, and systemd's service cgroup owns both processes.
Last updated