Raspberry Pi : install rTorrent and ruTorrent with Nginx

In this tutorial, Let's see how to install a torrent client that will be in charge of download for us. We will also configure it so that it is accessible from a web interface.

Raspberry Pi Home Server – Etape 12 : installer rTorrent et ruTorrent avec Nginx

You have the possibility to directly install rtorrent or recompile it with libtorrent.

If you want to compile rtorrent here are instructions :

  1. Download the latest version of rtorrent on official site then unpack
  2. Download the latest version of libtorrent on official site then unpack
  3. Install additional packages
     apt - get install subversion libcurl3-gnutls-dev build-essential make gcc autoconf curl build-essential libtool bison flex libreadline-dev autoconf automake libcppunit-dev libsigc    - 2.0 - dev libncursesw5-dev libncurses5-dev libxmlrpc-c3-dev
  4. Go to the directory of the sources of libtorrent, compile and install
    . /configure  make  make install
  5. Go to the directory of the sources of rtorrent, compile and install
    ./configure --with-xmlrpc-c  make  make install

The other possibility, plus simple et rapide 😀

apt - get install rtorrent dtach

It will install everything : rtorrent, libtorrent, dtach (We will see later what we do)

Turn to the suite

  1. Create the /etc/init.d/rtorrentd script
    #!/bin/sh e
    # Provides: rtorrentd
    # Required-Start: $network $syslog
    # Required-Stop: $network
    # Default-Start: 2 3 5
    # Default-Stop: 0 1 6
    # Description: Start/stop rtorrent as daemon.
    ### END INIT INFO   NAME=rtorrent  SCRIPTNAME=/etc/init.d/rtorrentd  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
    # path of the temporary file TMP=/tmp/rtorrent.dtach
    # user who launches the torrent USER = $NAME
    # chemin vers fichier conf  CONF=/home/$USER/.rtorrent.rc  start() {
            echo n "Starting $NAME: "
            su-l $USER UI "dtach n $TMP n o import rtorrent = $CONF"
            chmod 666 /tmp/rtorrent.dtach          echo "started" 
    stop() {
            echo n "Stopping $NAME: "
            killall r "rtorrent"
            echo "stopped"
    restart() { 
            if [ "$(ps aux | grep -e 'rtorrent' -c)" != 0  ]; then
                    stop                  sleep 5
            fi          start
    case $1 in          start)
                    echo "Use:  {Start|stop|restart}" >&2
                    exit 2
  2. Changer les droits du fichier
     chmod 755 rtorrentd
  3. Add the service to the Pi Home Server Raspberry boot
    update - rc.d defaults rtorrentd
  4. Add a user rtorrent
     adduser rtorrent
  5. Create the file .rtorrent.RC in /Home/rtorrent by changing the lines in red
     # Rtorrent. configuration file # by default, This is the ~/.rtorrent.rc file
    # Limits of the rate of download in reception and sending. "0" is equivalent to no limit.
    #download_rate = 500
    #upload_rate = 150
    # Directory that contains the downloaded files.
    Directory = ~/torrent/data
    # Directory where rtorrent stores the status of download of torrents.
    session = ~/torrent/session
    # Use a //relatif// path if you are likely to launch many
    # instances of rtorrent ! Comment the previous line and uncomment the :
    #session =. / session
    # Usable by rtorrent ports (use two times the same value for use anytime this port)
    port_range = 6881-6999
    port_random = no
    # Vérification des données à la fin du téléchargement  check_hash = yes
    # This directory contains files .torrent.
    # As soon as a new .torrent is added, the download begins.
    Schedule = watch_directory,15,15,load_start=~/torrent/torrent_active/*.torrent
    # As soon as the download is completed, the file is moved in the
    # Directory ~/torrent_finis.
    # For recent versions of rtorrent (0.8.4 and higher), use the following line :
    #System.method.set_key = event.download.finished,move_complete,"execute = mv,-u,$d.get_base_path =,~/torrent_finis/;d.set_directory=~/torrent_finis/"
    # For versions 0.7.7 from 0.8.3, use the following line :
    #on_finished = move_complete,"execute = mv,-u,$d.get_base_path =,~/torrent_finis/;d.set_directory=~/torrent_finis/"
    # Enable DHT for torrents without trackers.
    # It is mandatory to specify a session directory (see above).
    DHT = auto
    # UDP port for the use of DHT.
    dht_port = 6880
    # Force the use of encrypted transactions, to receive and send that protected data.
    # On the other hand, the identities of the sender and the recipient remain visible.
    encryption = allow_incoming,require,require_rc4  encoding_list = UTF-8  scgi_local = /home/rtorrent/scgi.socket  execute = chmod,UG = rw,o = rw,/Home/rtorrent/SCGI.Socket execute = chgrp,rtorrent,/Home/rtorrent/SCGI.Socket
  6. Change the owner of the file .rtorrent.RC as you have just done with the user root
    chown rtorrent:rtorrent. rtorrent.rc
  7. Create the directory defined in the file and session directories .rtorrent.RC. Directories must have as owner rtorrent (Ditto for the Group)
  8. Download interface rutorrent official website https://code.google.com/p/rutorrent/
  9. Unpack the archive in /var/www so as to have all the files in /var/www/rutorrent
  10. Configure the file /var/www/rutorrent/conf/config.php. Change the following lines :
    $scgi_port = 0;
    $scgi_host = "UNIX:////Home/rtorrent/SCGI.Socket";
  11. Create a server ruTorrent for Nginx. Create the file /etc/nginx/sites-available/rutorrent
    server {
     listen 8092; # You choose !
     index index.html;
     server_name rutorrent;
     error_log /var/log/nginx/rutorrent_error.log;
     access_log /var/log/nginx/rutorrent_access.log;
    location ~ .php$ {
     try_files $uri = 404;
     fastcgi_index index.php;
     fastcgi_split_path_info ^(.+.php)(/.+)$;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_pass unix:/var/run/PHP5-fpm.sock;
    rental /RPC2 {
     scgi_pass unix:/Home/rtorrent/SCGI.Socket;
     include scgi_params;
  12. Enable the site
    cd /etc/nginx/sites-enabled  ln -s /etc/nginx/sites-available/rutorrent rutorrent
  13. Restart Nginx
    service nginx restart
  14. It's party time, You can access your site rutorrent : http://<ipRaspberryPi>:8092/

Next step, a music with MPD Server !

You may also like...