Install rTorrent & ruTorrent with nginx on Debian 9

Here it comes the Update to the glorious Debian 8 – How to install rTorrent & ruTorrent with nginx.

Today we’ll be taking a minimal Debian 9 (stretch) system and set up a seedbox all from scratch, using rTorrent/libTorrent, ruTorrent and Nginx.

Install dependencies

without some packages we can’t start here….

apt-get update
apt-get upgrade

apt-get install nginx php7.0-fpm nano apache2-utils subversion git screen build-essential automake libtool libcppunit-dev libcurl3 libsigc++-2.0-dev curl unrar unzip libncurses5-dev libfuse-dev libcurl4-openssl-dev libxml++2.6-dev php7.0-cli php7.0-mbstring libssl-dev mediainfo

Create User

We need a user to run rTorrent. You can name it whatever you want, but if you chose something different, remember to adjust the configs in the rest of this article.

useradd rutorrent
mkdir -p /home/rutorrent
usermod -a -G rutorrent www-data
usermod -a -G www-data rutorrent


Install XMLRPC-C

These is needed for the communication between nginx and rTorrent.

git clone
cd xmlrpc-c/stable/
./configure --disable-cplusplus
make install


Install libtorrent

git clone -b feature-bind
cd libtorrent
./configure --disable-instrumentation
make install


Install rTorrent

Clone and compile. We need to make sure we configure –with-xmlrpc-c.

git clone -b feature-bind
cd rtorrent
./configure --with-xmlrpc-c
make install


Install and configure ruTorrent

This one is easy. We just need to clone the git repo into /var/www

mkdir -p /var/www
cd /var/www
git clone
chown -R www-data:www-data /var/www

now edit the conf/config.php

$topDirectory = "/home/rutorrent"
$scgi_port = 5000;
$scgi_host = ""

$pathToExternals = array(
                "php"   => '',                  // Something like /usr/bin/php. If empty, will be found in PATH.
                "curl"  => '/usr/bin/curl',     // Something like /usr/bin/curl. If empty, will be found in PATH.
                "gzip"  => '',                  // Something like /usr/bin/gzip. If empty, will be found in PATH.
                "id"    => '',                  // Something like /usr/bin/id. If empty, will be found in PATH.
                "stat"  => '/usr/bin/stat',     // Something like /usr/bin/stat. If empty, will be found in PATH.

the curl and the stat settings are need to set otherwise RSS wouldn’t work.


Configure Nginx

now we create a Site configuration for ruTorrent.
just create and edit this file: /etc/nginx/sites-enabled/rutorrent

server {
  listen 80;
  server_name localhost;

  root /var/www/ruTorrent;
  index index.html index.htm index.php;

  auth_basic "Restricted";
  auth_basic_user_file /etc/nginx/.htpasswd;

  location / {
    try_files $uri $uri/ =404;

  location /RPC2 {
    include /etc/nginx/scgi_params;

  location ~ .php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;

We also want it password-protected or you want the world to see all your “linux iso’s”?

htpasswd -c /etc/nginx/.htpasswd rutorrent

now delete the default settings and restart nginx and php5-fpm

rm -f /etc/nginx/sites-enabled/default
service nginx restart && service php7.0-fpm restart


Configure rTorrent

now we need to configure rTorrent here is a sample ~/.rtorrent.rc you can modify it but don’t delete the SCGI Socket line.

# ----------------------------------------------------------------------
# BitTorrent
# ----------------------------------------------------------------------

throttle.global_down.max_rate.set = 0
throttle.global_up.max_rate.set   = 0
throttle.max_peers.normal.set     = 200
throttle.max_peers.seed.set       = -1   = 200
throttle.min_peers.normal.set     = 1
throttle.min_peers.seed.set       = -1

# ----------------------------------------------------------------------
# Directories
# ----------------------------------------------------------------------

directory                        = /home/rutorrent/
session                          = /home/rutorrent/.session
#schedule                        = watch_directory,5,5,load_start=/root/rtorrent/watch/*.torrent
encoding.add                     = UTF-8

# ----------------------------------------------------------------------
# Network
# ----------------------------------------------------------------------

network.port_range.set           = 10001-11000
network.scgi.open_port           =
network.port_random.set          = yes
network.tos.set                  = throughput
protocol.pex.set                 = no
trackers.use_udp.set             = yes

encryption                       = allow_incoming,try_outgoing,enable_retry

# ----------------------------------------------------------------------
# Hash
# ----------------------------------------------------------------------

pieces.hash.on_completion.set    = no
check_hash                       = no

After that we need to create the .session directory.

mkdir -p /home/rutorrent/.session
chown -R rutorrent:rutorrent /home/rutorrent/
chown -R rutorrent:rutorrent /home/rutorrent/.rtorrent.rc


Configure rTorrent autostart

Many people will tell you to write an init script for this, but IMHO that’s overkill. I prefer to use /etc/rc.local

start-stop-daemon --start --chuid rutorrent --name rtorrent --exec /usr/bin/screen -- -fa -d -m /usr/local/bin/rtorrent


NOTE: In this setup is no ffmpeg installed so ruTorrent always complaining about it i don’t need it if you want it you can install it with the DebianMultimedia Repo.