How to Install LibreTranslate on Ubuntu 24.04 LibreTranslate is a self-hosted, open-source machine translation service. It provides a lightweight API and web interface for translating text between multiple languages without relying on cloud providers. This guide walks you through installing LibreTranslate on Ubuntu 24.04 with Python virtual environments, systemd service configuration, and firewall setup. Step 1: Update System and Install Dependencies Start by updating your package cache and installing required dependencies including Python, pip, git, and build tools. sudo apt update sudo apt install -y curl wget gnupg software-properties-common build-essential python3-pip python3-venv git time Step 2: Install Python 3.11 Ubuntu 24.04 comes with Python 3.12 by default, but LibreTranslate recommends Python 3.11. Add the deadsnakes PPA and install Python 3.11. sudo add-apt-repository ppa:deadsnakes/ppa -y sudo apt update sudo apt install -y python3.11 python3.11-venv python3.11-dev Step 3: Create User and Directories Create a dedicated system user for LibreTranslate and the necessary directories for code, virtual environment, logs, and data. sudo useradd -r -m -d /opt/libretranslate -s /bin/bash libretranslate sudo mkdir -p /opt/libretranslate/{venv,logs,data} sudo chown -R libretranslate:libretranslate /opt/libretranslate Step 4: Create Python Virtual Environment Set up a virtual environment to isolate LibreTranslate dependencies. sudo -u libretranslate python3.11 -m venv /opt/libretranslate/venv sudo -u libretranslate /opt/libretranslate/venv/bin/pip install --upgrade pip Note: The installation downloads ~3GB of libraries including Torch and language models. Expect 15–20 minutes for completion. Step 5: Install LibreTranslate Activate the virtual environment and install LibreTranslate using pip. sudo -u libretranslate bash -c " cd /opt/libretranslate source venv/bin/activate pip install libretranslate " Step 6: Install Gunicorn for Production Serving sudo -u libretranslate /opt/libretranslate/venv/bin/pip install gunicorn Step 7: Configure Systemd Service Create a systemd service to run LibreTranslate as a background service. sudo nano /etc/systemd/system/libretranslate.service Paste the following: [Unit] Description=LibreTranslate Translation Service After=network.target [Service] Type=exec User=libretranslate WorkingDirectory=/opt/libretranslate Environment="PATH=/opt/libretranslate/venv/bin" ExecStart=/opt/libretranslate/venv/bin/libretranslate \ --host 0.0.0.0 \ --port 5000 \ --load-only en,es \ --threads 2 Restart=always RestartSec=5 StandardOutput=journal StandardError=journal NoNewPrivileges=yes PrivateTmp=yes ProtectSystem=strict ProtectHome=yes ReadWritePaths=/opt/libretranslate [Install] WantedBy=multi-user.target Reload systemd and start the service: sudo systemctl daemon-reload sudo systemctl enable --now libretranslate Step 8: Firewall Configuration If UFW is active, allow access to LibreTranslate’s port: sudo ufw allow 5000/tcp sudo ufw reload Step 9: Create Helper Scripts Startup script: nano /opt/libretranslate/start.sh #!/bin/bash cd /opt/libretranslate source venv/bin/activate libretranslate --host 0.0.0.0 --port 5000 --load-only en,es --threads 2 Update script: nano /opt/libretranslate/update.sh #!/bin/bash cd /opt/libretranslate source venv/bin/activate pip install -U libretranslate libretranslate --update-models --load-only en,es Make both executable: sudo chmod +x /opt/libretranslate/{start.sh,update.sh} sudo chown libretranslate:libretranslate /opt/libretranslate/{start.sh,update.sh} Step 10: Access LibreTranslate Once the service is running, access LibreTranslate via: Web Interface / API: http://<server-ip>:5000 Example API Request: curl -X POST "http://<server-ip>:5000/translate" \ -H "Content-Type: application/json" \ -d '{"q":"Hello world","source":"en","target":"es"}' Conclusion You now have a fully functional LibreTranslate installation on Ubuntu 24.04. It runs securely under a dedicated system user, uses a Python virtual environment, and starts automatically with systemd. Your translation service is ready for API integrations, web applications, or personal use, all without relying on external cloud providers.