Python AI Installation and Configuration
Installation on Ubuntu 24.04
Verify Python version
Must be 3.12.*
Install Supervisor
Deploying from DeployHQ
Create a server deployment from the Method Grid app repository to the python server.
Follow DeployHQ's instructions for giving DeployHQ access to the server, then set the following options:
- Deployment path: /usr/src/ai
- Environment: production
- Subdirectory to deploy from: ai/
Deploy the code.
Install dependencies
Create virtual environment and install dependencies:
apt-get update && apt-get install -y python3.12-venv
python3 -m venv /usr/src/ai/.venv
/usr/src/ai/.venv/bin/pip install --upgrade pip
/usr/src/ai/.venv/bin/pip install /usr/src/ai
Create .env file
Copy example .env file:
Edit .env file with correct values.
Configuration
Create Python AI Supervisor .conf File
Create /etc/supervisor/conf.d/ai-websocket.conf:
[program:ai-websocket]
command=/usr/src/ai/.venv/bin/python /usr/src/ai/src/mg_ai/main.py
autostart=true
autorestart=true
stderr_logfile=/var/log/ai.error.log
stdout_logfile=/var/log/ai.log
Restart Supervisor
Verify that AI websocket server is running
Create Firewall Rules
The AI Python server firewall must allow incoming connections to ports 8000 from all web servers.
Webserver Proxy
This is handled by the apache config on the webservers and is covered by the instructions there. The key point is that the apache virtual host must include the following: