Ubuntu Server Installation
Prerequisites
System Requirements
Ubuntu Server (22.04 LTS or later recommended)
Minimum 2GB RAM
Clean installation recommended
Domain and DNS Setup (Required)
Cloudflare Account Setup
Create a Cloudflare account if you don't have one
Add your domain to Cloudflare
Update your domain's nameservers to Cloudflare's nameservers
DNS Configuration
Add an A record pointing to your server's IP address
Type: A Name: yourdomain.com Content: YOUR_SERVER_IP Proxy status: Proxied
Add a CNAME record for the domain (optional). Not required for sub.yourdomain.com
Type: CNAME Name: www Content: yourdomain.com Proxy status: Proxied
SSL/TLS Configuration in Cloudflare
Go to SSL/TLS section
Set encryption mode to "Full (strict)"
Broker Setup (Required)
Obtain your broker's API credentials as per the openalgo documentation:
API Key
API Secret
Prepare the Redirection URL as per your domain name and broker name
# Example - domain name is yourdomain.com and broker is icici
https://yourdomain.com/icici/callback
# Example - domain name is sub.yourdomain.com and broker is angel
https://sub.yourdomain.com/angel/callback
Login to the Ubuntu Server
# Connect to your Ubuntu server via SSH
# example ssh [email protected]
ssh user@your_server_ip
Installation Steps
1. Download Installation Script
# Create a directory for installation
mkdir -p ~/openalgo-install
cd ~/openalgo-install
# Download the installation script
wget https://raw.githubusercontent.com/marketcalls/openalgo/main/install/install.sh
# Make the script executable
chmod +x install.sh
2. Run Installation Script
# Execute the installation script
sudo ./install.sh
The script will interactively prompt you for:
Your domain name (supports both root domains and subdomains)
Broker selection
Broker API credentials
The installation process will:
Install required packages
Configure Nginx with SSL
Set up the OpenAlgo application
Create systemd service with unique name based on domain and broker
Generate installation logs in the logs directory
Multi-Domain Deployment
The installation script supports deploying multiple instances on the same server:
Each deployment gets a unique service name (e.g., openalgo-yourdomain-broker)
Separate configuration files and directories for each deployment
Individual log files for each installation in the logs directory
Independent SSL certificates for each domain
Isolated Python virtual environments
Example of running multiple deployments:
# First deployment
sudo ./install.sh
# Enter domain: trading1.yourdomain.com
# Enter broker: fyers
# Second deployment
sudo ./install.sh
# Enter domain: trading2.yourdomain.com
# Enter broker: zerodha
Each deployment will:
Have its own systemd service
Use separate configuration files
Store logs in unique timestamped files
Run independently of other deployments
3. Verify Installation
After installation completes, verify each deployment:
Check Service Status
# Example for Fyers deployment sudo systemctl status openalgo-fyers-yourdomain-fyers # Example for Zerodha deployment sudo systemctl status openalgo-zerodha-yourdomain-zerodha
Verify Nginx Configuration
# Test overall Nginx configuration sudo nginx -t # Check specific site configurations ls -l /etc/nginx/sites-enabled/ cat /etc/nginx/sites-enabled/fyers.yourdomain.com cat /etc/nginx/sites-enabled/zerodha.yourdomain.com
Access Web Interfaces Test each deployment in your web browser:
https://fyers.yourdomain.com https://zerodha.yourdomain.com
Check Installation Logs
# View the installation log for your deployment cat install/logs/install_YYYYMMDD_HHMMSS.log
Troubleshooting
Common Issues
SSL Certificate Issues
# Check Certbot logs sudo journalctl -u certbot # Example: Manually run certificate installation for trading.yourdomain.com sudo certbot --nginx -d trading.yourdomain.com # Example: Manually run certificate installation for multiple subdomains sudo certbot --nginx -d fyers.yourdomain.com -d zerodha.yourdomain.com
Application Not Starting Example scenario: Managing multiple broker deployments
# Example 1: Fyers deployment on fyers.yourdomain.com sudo journalctl -u openalgo-fyers-yourdomain-fyers # View logs sudo systemctl restart openalgo-fyers-yourdomain-fyers # Restart service # Example 2: Zerodha deployment on zerodha.yourdomain.com sudo journalctl -u openalgo-zerodha-yourdomain-zerodha # View logs sudo systemctl restart openalgo-zerodha-yourdomain-zerodha # Restart service
Nginx Issues
# Check Nginx error logs for all deployments sudo tail -f /var/log/nginx/error.log # Check access logs for specific domains sudo tail -f /var/log/nginx/fyers.yourdomain.com.access.log sudo tail -f /var/log/nginx/zerodha.yourdomain.com.access.log
Installation Logs Example: Checking installation logs for multiple deployments
# List all installation logs ls -l install/logs/ # View latest installation log cat install/logs/$(ls -t install/logs/ | head -1) # Example: View specific deployment logs cat install/logs/install_20240101_120000.log # Fyers installation cat install/logs/install_20240101_143000.log # Zerodha installation
Managing Multiple Deployments
Service Management Examples
# List all OpenAlgo services systemctl list-units "openalgo-*" # Example outputs: # openalgo-fyers-yourdomain-fyers.service loaded active running # openalgo-zerodha-yourdomain-zerodha.service loaded active running # Restart specific deployment sudo systemctl restart openalgo-fyers-yourdomain-fyers # Check status of specific deployment sudo systemctl status openalgo-zerodha-yourdomain-zerodha
Log Management Examples
# View real-time logs for Fyers deployment sudo journalctl -f -u openalgo-fyers-yourdomain-fyers # View last 100 lines of Zerodha deployment logs sudo journalctl -n 100 -u openalgo-zerodha-yourdomain-zerodha # View logs since last hour for specific deployment sudo journalctl --since "1 hour ago" -u openalgo-fyers-yourdomain-fyers
Nginx Configuration Examples
# View Nginx configs for different deployments sudo nano /etc/nginx/sites-available/fyers.yourdomain.com sudo nano /etc/nginx/sites-available/zerodha.yourdomain.com # Test Nginx configuration sudo nginx -t # Reload Nginx after config changes sudo systemctl reload nginx
Installation Directory Examples
# List deployment directories ls -l /var/python/openalgo-flask/ # Example structure: # /var/python/openalgo-flask/fyers-yourdomain-fyers/ # /var/python/openalgo-flask/zerodha-yourdomain-zerodha/ # Check specific deployment files ls -l /var/python/openalgo-flask/fyers-yourdomain-fyers/
Security Notes
Firewall
The installation configures UFW to allow only HTTP, HTTPS, and SSH
Additional ports can be opened if needed:
sudo ufw allow <port_number>
SSL/TLS
Certificates are automatically renewed by Certbot
The installation configures modern SSL parameters
Regular updates are recommended:
sudo apt update && sudo apt upgrade -y
Post-Installation
Configure your broker settings in the web interface
Set up monitoring and alerts if needed
Regularly check logs for any issues
Keep the system updated with security patches
Support
For issues and support:
Check the GitHub repository
Review the logs using commands provided above
Contact support with relevant log information
Remember to:
Regularly backup your configuration
Monitor system resources
Keep the system updated
Review security best practices
Last updated