How to install rtorrent and rutorrent on ubuntu linux
Here’s a clean way to install rTorrent + ruTorrent on Ubuntu
(works well on 20.04/22.04; adapt versions/paths as needed)
1. Install base packages
Install rTorrent, nginx (or Apache) and PHP-FPM:
Bash:
sudo apt update
sudo apt install rtorrent screen nginx php-fpm php-cli php-curl php-xml php-zip php-mbstring php-json unzip git
Optional (but recommended):
Bash:
sudo apt install mediainfo ffmpeg unrar-free
2. Create rTorrent user + directories
Either use your existing user or create a dedicated one:
Bash:
sudo adduser --disabled-password --gecos "" rtorrent
Create directories for downloads and session:
Bash:
sudo -u rtorrent mkdir -p /home/rtorrent/{downloads,watch,.session}
3. Configure rTorrent (~/.rtorrent.rc)
As the
rtorrent user:
Bash:
sudo -u rtorrent -s
nano /home/rtorrent/.rtorrent.rc
Minimal example:
Bash:
directory = /home/rtorrent/downloads
session = /home/rtorrent/.session
schedule = watch_directory,5,5,load_start=/home/rtorrent/watch/*.torrent
# Network / ports
port_range = 51413-51413
port_random = no
# Encryption
encryption = allow_incoming,try_outgoing,enable_retry
# DHT / PEX
dht = auto
dht_port = 6881
peer_exchange = yes
# SCGI for ruTorrent
scgi_port = 127.0.0.1:5000
# UI tweaks
use_udp_trackers = yes
check_hash = yes
Exit the shell or switch back to your user when done.
4. Run rTorrent as a service (recommended)
Create a systemd service so rTorrent runs in the background:
Bash:
sudo nano /etc/systemd/system/rtorrent.service
Put this inside:
INI:
[Unit]
Description=rTorrent
After=network.target
[Service]
Type=simple
User=rtorrent
Group=rtorrent
WorkingDirectory=/home/rtorrent
ExecStart=/usr/bin/screen -DmS rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/killall -w rtorrent
Restart=on-failure
[Install]
WantedBy=multi-user.target
Enable and start it:
Bash:
sudo systemctl daemon-reload
sudo systemctl enable rtorrent
sudo systemctl start rtorrent
sudo systemctl status rtorrent
(You can attach later with
sudo -u rtorrent screen -r rtorrent.)
5. Install ruTorrent
Put ruTorrent under nginx’s web root (example:
/var/www/rutorrent):
Bash:
cd /var/www
sudo git clone https://github.com/Novik/ruTorrent.git rutorrent
sudo chown -R www-data:www-data /var/www/rutorrent
6. Configure ruTorrent to talk to rTorrent (SCGI)
Edit the main config:
Bash:
sudo nano /var/www/rutorrent/conf/config.php
Set the SCGI address/port to match
.rtorrent.rc:
PHP:
<?php
$scgi_port = 5000;
$scgi_host = "127.0.0.1";
$XMLRPCMountPoint = "/RPC2";
(Leave the rest default for a basic setup.)
7. Configure nginx virtual host
Create a site config:
Bash:
sudo nano /etc/nginx/sites-available/rutorrent
Example config (HTTP only for simplicity):
NGINX:
server {
listen 80;
server_name yourdomain.com;
root /var/www/rutorrent;
index index.php index.html;
access_log /var/log/nginx/rutorrent_access.log;
error_log /var/log/nginx/rutorrent_error.log;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock; # adjust if your socket path differs
}
# SCGI proxy to rTorrent
location /RPC2 {
include scgi_params;
scgi_pass 127.0.0.1:5000;
}
}
Enable the site and reload nginx:
Bash:
sudo ln -s /etc/nginx/sites-available/rutorrent /etc/nginx/sites-enabled/rutorrent
sudo nginx -t
sudo systemctl reload nginx
8. Permissions for downloads
Make sure the web server can access the download path if needed (for plugins):
Bash:
sudo usermod -a -G rtorrent www-data
sudo chown -R rtorrent:rtorrent /home/rtorrent
sudo chmod -R 775 /home/rtorrent
Log out/in (or restart PHP-FPM) so group changes take effect.
9. Access ruTorrent
Open in your browser:
http://yourdomain.com/ or http://server_ip/
You should see the ruTorrent web UI. If it shows “No connection to rTorrent”, double-check:
scgi_port + scgi_host in .rtorrent.rc
/RPC2 location + scgi_pass in nginx config
- That the
rtorrent service is running
10. Security notes
For production/Internet-facing:
- Put ruTorrent behind HTTPS (Let’s Encrypt with nginx).
- Add basic auth or another auth layer in nginx.
- Restrict access by IP / VPN if possible.