├── .env ├── LICENSE ├── README.md ├── get-cert.sh ├── libretranslate.service ├── nginx ├── run.sh ├── setup.sh └── update.sh /.env: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/argosopentech/LibreTranslate-init/553e884a45de6f67fb842dd281c662db1000cce3/.env -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Argos Open Tech 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LibreTranslate-init 2 | 3 | Shell scripts to install [LibreTranslate](https://libretranslate.com) 4 | 5 | Uses WSGI with [Gunicorn and Nginx](https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-gunicorn-and-nginx-on-ubuntu-18-04). 6 | 7 | Tested on Ubuntu 20.04. 8 | 9 | [Known Python version bug with Ubuntu 24.04](https://github.com/LibreTranslate/LibreTranslate/issues/611#issuecomment-2415239429) and Python 3.12. 10 | 11 | ## Install 12 | 13 | ``` 14 | # Create libretranslate user 15 | useradd libretranslate 16 | mkdir /home/libretranslate 17 | chown libretranslate:libretranslate /home/libretranslate 18 | usermod -aG sudo libretranslate 19 | passwd -d libretranslate 20 | su libretranslate 21 | 22 | # Download LibreTranslate-init 23 | git clone https://github.com/argosopentech/LibreTranslate-init.git ~/LibreTranslate-init 24 | 25 | # Download dependencies and run LibreTranslate on port 5000 26 | ~/LibreTranslate-init/setup.sh 27 | 28 | # Add your hostname or IP address to this command 29 | # When you run LibreTranslate for the first time it will download all of the language model packages 30 | ~/LibreTranslate/env/bin/libretranslate --host 31 | 32 | # Set server_name to your domain name in ~/LibreTranslate-init/nginx 33 | 34 | # Run LibreTranslate WSGI with nginx and systemd 35 | ~/LibreTranslate-init/run.sh 36 | 37 | # Check LibreTranslate status 38 | sudo systemctl status libretranslate 39 | 40 | # Enable https 41 | ~/LibreTranslate-init/get-cert.sh 42 | 43 | ``` 44 | 45 | #### Tutorials 46 | - [Video tutorial](https://www.youtube.com/watch?v=mwacU-yqJwc) 47 | - [Video tutorial 2](https://www.youtube.com/watch?v=SJ8lNcn4cjE) 48 | - [Video tutorial 3](https://www.youtube.com/watch?v=dKR28QaaWLo) 49 | 50 | #### Configuration 51 | 1. Find the setting you would like to change in the [LibreTranslate settings](https://github.com/LibreTranslate/LibreTranslate#arguments) 52 | 2. Add the setting to the `.env` file 53 | -------------------------------------------------------------------------------- /get-cert.sh: -------------------------------------------------------------------------------- 1 | # Setup TLS with certbot and Let's Encrypt 2 | # https://certbot.eff.org/ 3 | 4 | sudo apt install certbot python3-certbot-nginx 5 | sudo certbot --nginx 6 | sudo certbot renew --dry-run 7 | 8 | -------------------------------------------------------------------------------- /libretranslate.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=LibreTranslate WSGI with Gunicorn and Nginx 3 | After=network.target 4 | 5 | [Service] 6 | User=libretranslate 7 | Group=www-data 8 | WorkingDirectory=/home/libretranslate/LibreTranslate 9 | Environment="PATH=/home/libretranslate/LibreTranslate/env/bin" 10 | ExecStart=/home/libretranslate/LibreTranslate/env/bin/gunicorn --workers 3 --bind unix:libretranslate.sock -m 007 wsgi:app 11 | EnvironmentFile=/home/libretranslate/LibreTranslate-init/.env 12 | Restart=always 13 | ExecReload=/bin/kill -s HUP $MAINPID 14 | KillMode=mixed 15 | TimeoutStopSec=1 16 | 17 | [Install] 18 | WantedBy=multi-user.target 19 | -------------------------------------------------------------------------------- /nginx: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | server_name _; 4 | 5 | location / { 6 | include proxy_params; 7 | proxy_pass http://unix:/home/libretranslate/LibreTranslate/libretranslate.sock; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | # Setup systemd 2 | sudo cp ~/LibreTranslate-init/libretranslate.service /etc/systemd/system/ 3 | sudo systemctl start libretranslate 4 | sudo systemctl enable libretranslate 5 | # sudo systemctl status libretranslate 6 | 7 | # Configure Nginx 8 | sudo cp ~/LibreTranslate-init/nginx /etc/nginx/sites-available/default 9 | sudo nginx -t 10 | sudo systemctl restart nginx 11 | 12 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | sudo apt-get update 2 | sudo apt-get upgrade -y 3 | sudo apt-get install -y vim git 4 | 5 | # Install Python 6 | sudo apt-get install -y python3 python3-virtualenv python-is-python3 python3-pip python3-dev build-essential libssl-dev libffi-dev python3-setuptools 7 | 8 | # Install PyICU dependencies 9 | # https://community.libretranslate.com/t/pyicu-fails-to-install-on-ubuntu-20-04/23 10 | sudo apt-get install -y libicu-dev python3-icu pkg-config 11 | 12 | # Install Nginx 13 | sudo apt-get install -y nginx 14 | 15 | # Download LibreTranslate source 16 | git clone https://github.com/LibreTranslate/LibreTranslate.git ~/LibreTranslate 17 | 18 | # Setup virtualenv 19 | virtualenv ~/LibreTranslate/env 20 | 21 | # Install gunicorn 22 | ~/LibreTranslate/env/bin/pip install gunicorn 23 | 24 | # Install and run LibreTranslate on port 5000 25 | ~/LibreTranslate/env/bin/pip install ~/LibreTranslate/ --no-cache-dir 26 | 27 | -------------------------------------------------------------------------------- /update.sh: -------------------------------------------------------------------------------- 1 | cd ~/LibreTranslate-init 2 | git pull 3 | rm -rf ~/LibreTranslate/env 4 | virtualenv ~/LibreTranslate/env 5 | ~/LibreTranslate/env/bin/pip install ~/LibreTranslate/ --no-cache-dir 6 | ~/LibreTranslate/env/bin/libretranslate --update-models 7 | --------------------------------------------------------------------------------