«

»

May 09

How to Install and Configure: ruTorrent, rTorrent, Libtorrent, XMLRPC, Screen (Debian 8 Jessie).

Add your username to /etc/sudoers.

su

root password.

 nano /etc/sudoers

Example:

john         ALL=(ALL) ALL

 

1. Create new user “rtorrent”.

sudo adduser --home /opt/rtorrent rtorrent

 

2. Update Everything and install some needed dependencies.

sudo apt-get update
sudo apt-get upgrade

sudo apt-get install subversion build-essential automake libtool libcppunit-dev libcurl3-dev
sudo apt-get install libsigc++-2.0-dev libcppunit-dev unzip unrar-free curl libncurses-dev 
sudo apt-get install apache2 apache2-utils php5 php5-cli php5-curl php-xml-rss php5-xmlrpc
sudo apt-get install php5-sqlite sqlite libapache2-mod-php5 libapache2-mod-xsendfile

 

3. Enable the SCGI module.

 

sudo apt-get install libapache2-mod-scgi
sudo ln -s /etc/apache2/mods-available/scgi.load /etc/apache2/mods-enabled/scgi.load
sudo /etc/init.d/apache2 restart

 

4. Instalacja XMLRPC.

cd $HOME
sudo mkdir install
cd install
sudo svn checkout http://svn.code.sf.net/p/xmlrpc-c/code/stable xmlrpc-c
cd xmlrpc-c
sudo ./configure --disable-cplusplus
sudo make
sudo make install

 

5. Instalacja rTorrent.

5.1. Instalacja bibliotek Libtorrent.
cd ..
sudo wget https://github.com/rakshasa/libtorrent/archive/0.13.4.tar.gz -O libtorrent-0.13.4.tar.gz
sudo tar xvf libtorrent-0.13.4.tar.gz
cd libtorrent-0.13.4
sudo ./autogen.sh
sudo ./configure
sudo make
sudo make install

 

5.2. Instalacja rTorrent.
cd ..
sudo wget https://github.com/rakshasa/rtorrent/archive/0.9.4.tar.gz -O rtorrent-0.9.4.tar.gz
sudo tar xvf rtorrent-0.9.4.tar.gz
cd rtorrent-0.9.4
sudo ./autogen.sh
sudo ./configure --with-xmlrpc-c
sudo make
sudo make install
sudo ldconfig

 

6. Make Directories these are needed for rTorrent to function.

 

sudo mkdir -p /opt/rtorrent/{session,watch,download}
sudo chmod 777 -R /opt/rtorrent/{session,watch,download}
sudo chown rtorrent:rtorrent -R /opt/rtorrent/{session,watch,download}

 

7. Edit the .rtorrent.rc file and put it in the home directory of the user that will run rTorrent.

 

sudo wget https://raw.githubusercontent.com/rakshasa/rtorrent/master/doc/rtorrent.rc -O /opt/rtorrent/.rtorrent.rc

 

sudo nano /opt/rtorrent/.rtorrent.rc

  Edit: directory, session, watch_directory, port_range and add scgi port: scgi_port.

directory = /opt/rtorrent/download
session = /opt/rtorrent/session
#schedule = watch_directory,5,5,load_start=/opt/rtorrent/watch/*.torrent
port_range = 6882-6892
upload_rate = 0
download_rate = 0
use_udp_trackers = yes
max_uploads = 200
min_peers=10
max_peers=400
check_hash = no

# DHT
peer_exchange = yes
dht_port = 1026
dht = auto

# Encryption
encryption = allow_incoming,try_outgoing,require,require_RC4,prefer_plaintext,enable_retry

# SCGI
scgi_port = localhost:5000

  Change permission of rtorrent.rc config file.

sudo chown rtorrent:rtorrent /opt/rtorrent/.rtorrent.rc

 

8. Install ruTorrent.

 

8.1. ruTorrent via GIT.

 

sudo apt-get install git
sudo git clone https://github.com/Novik/ruTorrent.git /var/www/rutorrent/
sudo chown -R www-data:www-data /var/www/rutorrent

  OR

8.2. ruTorrent ver. 3.7.

 

cd ..
sudo wget https://bintray.com/artifact/download/novik65/generic/ruTorrent-3.7.zip
sudo unzip ruTorrent-3.7.zip
sudo mv ruTorrent-master /var/www/rutorrent
sudo chown -R www-data:www-data /var/www/rutorrent

    OR

8.3. ruTorrent ver. 3.6.

 

cd ..
sudo wget http://dl.bintray.com/novik65/generic/rutorrent-3.6.tar.gz
sudo tar xvf rutorrent-3.6.tar.gz
sudo mv rutorrent /var/www
sudo wget http://dl.bintray.com/novik65/generic/plugins-3.6.tar.gz
sudo tar xvf plugins-3.6.tar.gz
sudo mv plugins /var/www/rutorrent
sudo chown -R www-data:www-data /var/www/rutorrent

OR

8.4. ruTorrent ver. 3.5.

 

cd ..
sudo wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/rutorrent/rutorrent-3.5.tar.gz
sudo tar xvf rutorrent-3.5.tar.gz
sudo mv rutorrent /var/www
sudo wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/rutorrent/plugins-3.5.tar.gz
sudo tar xvf plugins-3.5.tar.gz
sudo mv plugins /var/www/rutorrent
sudo rm -rf /var/www/rutorrent/plugins/darkpal
sudo chown -R www-data:www-data /var/www/rutorrent

 

8.5. ruTorrent mobile.

Acces to ruTorrent, rTorrent from Apple smartphones and older smartphones. http://terminal28.com/access-to-rutorrent-rtorrent-from-iphone-and-older-mobile-phones/   Acces to ruTorrent, rTorrent from Android smartphones. http://www.transdroid.org/.

Update path to Download directory.

Edit ruTorrent’s config.php config file and change path to Download directory. Locate $topDirectory and add path to Download directory (/opt/rtorrent/download):

sudo nano /var/www/rutorrent/conf/config.php

 

$topDirectory = '/opt/rtorrent/download'; // Upper available directory. Absolute path with trail slash.

 

8.6. Install mediainfo.

 

sudo apt-get install mediainfo

 

8.7. Install GeoIP i ffmpeg.

 

sudo wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
sudo gunzip GeoLiteCity.dat.gz
sudo mkdir -v /usr/share/GeoIP
sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat
sudo apt-get install php5-geoip libav-tools

 

sudo ln -s /usr/bin/avconv /usr/bin/ffmpeg

  Package ffmpeg is deprecated.

sudo apt-get install ffmpeg

 

9. Create the .htpasswd file.

 

cd /var/www/rutorrent

 

sudo htpasswd -c /var/www/rutorrent/.htpasswd username

  You will be asked for a password twice. Response:

New password:
Re-type new password:
Adding password for user username

  Edit file /var/www/rutorrent/.htaccess and add location secured by password.

sudo nano /var/www/rutorrent/.htaccess

 

...

 

AuthUserFile /var/www/rutorrent/.htpasswd
AuthName "ruTorrent_login"
AuthType Basic
require valid-user

 

...

  Configure access to rutorrent. Edit /etc/apache2/sites-available/rutorrent and add infoformation about: alias, files and location secured by password.  

sudo nano /etc/apache2/sites-available/rutorrent.conf

 

 # ruTorrent
#===========================================================================
<IfModule alias_module>

Alias /rutorrent        /var/www/rutorrent/

<Directory /var/www/rutorrent/>

Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride all
Require all granted

</Directory>

</IfModule>
#===========================================================================

 

Enable ruTorrent WebUI.

sudo ln -s /etc/apache2/sites-available/rutorrent.conf /etc/apache2/sites-enabled/rutorrent.conf

 

Enable modules auth_digest and authn_file:

sudo a2enmod auth_digest
sudo a2enmod authn_file

 

Restart apache2:

sudo /etc/init.d/apache2 restart

 

10. Secure SCGI (/RPC2).

Create folders: passwords-available, passwords-enabled in /etc/apache2.

sudo mkdir -p /etc/apache2/passwords-{available,enabled}

 

Go to /etc/apache2/passwords-available and make a new password for SCGI.

cd /etc/apache2/passwords-available
sudo htpasswd -c rtorrentscgi.conf username

 

Enable rtorrentscgi password.
Link folder passwords-available to passwords-enabled.

cd ../passwords-enabled
sudo ln -s ../passwords-available/rtorrentscgi.conf

 

Edit file /etc/apache2/sites-available/rtorrentscgi and add location of SCGI secured by password.

sudo nano /etc/apache2/sites-available/rtorrentscgi.conf

#rTorrent SCGI Password Location
#===========================================================================
        <LocationMatch "/RPC2">
                AuthType        Basic
                AuthName        "rtorrentscgi"
                AuthUserFile    /etc/apache2/passwords-enabled/rtorrentscgi.conf
                Require         valid-user
                BrowserMatch    "MSIE"  AuthDigestEnableQueryStringHack=On
                Require ip 127.0.0.1
        </LocationMatch>
#===========================================================================

# SCGI PORT
#===========================================================================

#LoadModule scgi_module /usr/lib/apache2/modules/mod_scgi.so
SCGIMount /RPC2 127.0.0.1:5000

#===========================================================================

 

Enable rtorrentscgi config.

sudo ln -s /etc/apache2/sites-available/rtorrentscgi.conf /etc/apache2/sites-enabled/rtorrentscgi.conf

 

Restart apache2.

sudo /etc/init.d/apache2 restart

 

11. Install Screen.

sudo apt-get install screen

 

Start rTorrent in a detached shell using screen.

su - rtorrent
screen -fa -d -m rtorrent

 

Testing rTorrent:

sudo netstat -npl | grep rtorrent

 

Response..

tcp    0  0 127.0.0.1:5000      0.0.0.0:*           LISTEN  6642/rtorrent   
tcp    0  0 0.0.0.0:6892        0.0.0.0:*           LISTEN  6642/rtorrent

 

13. Autostart rTorrent – systemd.

Create rtorrent autostart script for systemd.

sudo nano /etc/systemd/system/rtorrent.service
[Unit]
Description=rTorrent
After=network.target

[Service]
UMask=077
Type=forking
KillMode=none
User=rtorrent
ExecStartPre=-/bin/rm -f /opt/rtorrent/session/rtorrent.lock
ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/local/bin/rtorrent
ExecStop=/usr/bin/killall -w -s 2 /usr/local/bin/rtorrent
WorkingDirectory=/opt/rtorrent/

[Install]
WantedBy=multi-user.target

 

Enable rtorrent autostart.

sudo systemctl enable rtorrent.service

 

From now rTorrent will start with system automatically in a detached shell using screen.

Commands:

sudo service rtorrent start       - start
sudo service rtorrent stop        - stop
sudo service rtorrent restart     - restart

or

sudo systemctl start rtorrent     - start
sudo systemctl stop rtorrent      - stop
sudo systemctl restart rtorrent   - restart

 

14. Access to your web front-end for rTorrent.

http://address_IP/rutorrent

or

http://domain.com/rutorrent

 

You should be asked for username and password to access website

 

Links:
http://libtorrent.rakshasa.no/
http://code.google.com/p/rutorrent/
http://code.google.com/p/avalanche-rt/

 

14 comments

Skip to comment form

  1. Chris

    The URL http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.4.tar.gz is not working. In fact, rakshasa.no is not responding at all.

    I was able to obtain libtorrent and rtorrent from rakshasa’s repository on github and they appear to be the latest (0.9.4 / 0.13.4) when I run rtorrent on the command line without a .rtorrent.rc file.

    When I do have a generic .rtorrent.rc file in place, rtorrent exits with errors:

    Command “use_udp_trackers” does not exist
    Command “peer_exchange” does not exist

    Using “trackers.use_udp.set” in place of “use_udp_trackers” appears to work but I don’t the alternative for “peer_exchange”.

    Any advice?

    1. sethuper

      There weren’t any changes since ages in the rtorrent.rc file.
      See the original file from github:
      https://github.com/rakshasa/rtorrent/blob/master/doc/rtorrent.rc

  2. Jorge

    Thank you very much!

    It works like a charm!!!

  3. lombervid

    Hello.

    Thanks for the tutorial.

    I followed the steps, but when I enter to the WebUI I get this message:

    No connection to rTorrent. Check if it is really running. Check $scgi_port and $scgi_host settings in config.php and scgi_port in rTorrent configuration file

    Best regards!

    1. sethuper

      If you didn’t change anything..
      – make sure rtorrent started as user rtorrent (11. Install Screen.),
      – check apache logs.

      or run rtorrent like this:

      su - rtorrent
      /usr/bin/screen -d -m -fa -S rtorrent /usr/local/bin/rtorrent

      1. lombervid

        When I run:

        sudo netstat -npl | grep rtorrent

        I get only:

        tcp 0 0 0.0.0.0:6960 0.0.0.0:* LISTEN 2208/rtorrent

        but doing the other way you mention I get the same result.

        In apache log I have:

        [Sat Jul 04 10:48:55.890477 2015] [auth_digest:notice] [pid 3051] AH01757: generating secret for digest authentication …
        [Sat Jul 04 10:48:55.943670 2015] [mpm_prefork:notice] [pid 3051] AH00163: Apache/2.4.10 (Debian) mod_scgi/1.13 configured — resuming normal operations
        [Sat Jul 04 10:48:55.943734 2015] [core:notice] [pid 3051] AH00094: Command line: ‘/usr/sbin/apache2’

        P.D: Sorry, I’m really new on Linux system :(.

        Best Regards!

        1. sethuper

          Make sure you created rtorrent.rc file or start this tutorial again, cos you missed couple things I think.

          1. lombervid

            I have the file.

            I could see an error when the system is loading, some like:

            [FAILED] Failed to load rtorrent.

            Then I cheched and I got this:

            dll@lombervid:~$ sudo systemctl status rtorrent
            ● rtorrent.service – rTorrent
            Loaded: loaded (/etc/systemd/system/rtorrent.service; enabled)
            Active: failed (Result: exit-code) since dom 2015-07-05 00:10:49 CDT; 5min ago
            Process: 2127 ExecStop=/usr/bin/killall -w -s 2 /usr/local/bin/rtorrent (code=exited, status=1/FAILURE)
            Process: 2122 ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/local/bin/rtorrent (code=exited, status=0/SUCCESS)
            Main PID: 2123 (code=exited, status=0/SUCCESS)

            jul 05 00:10:49 lombervid killall[2127]: /usr/local/bin/rtorrent: no process found
            jul 05 00:10:49 lombervid systemd[1]: rtorrent.service: control process exited, code=exited status=1
            jul 05 00:10:49 lombervid systemd[1]: Unit rtorrent.service entered failed state.
            dll@lombervid:~$

          2. lombervid

            I did every step again, and I still getting the same.

          3. sethuper

            rtorrent could crash after first time, make sure this file: rtorrent.lock is not in the session folder before you run again.
            remove if exist:
            rm -fr /opt/rtorrent/sessions/rtorrent.lock
            then run rtorrent again.

            try to run rtorrent as user rtorrent
            su - rtorrent
            rtorrent
            or
            screen rtorrent
            or
            /usr/bin/screen -d -m -fa -S rtorrent /usr/local/bin/rtorrent

  4. mirtouf

    Hi,

    your copy paste failed for rtorrent.rc :
    system.method.insert=movedir1,simple,”d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_cust$

    like it was truncated.
    It may source of the problems described above.

    1. sethuper

      If it fails then do not copy those lines, I still test it, and i don’t get any errors works for me fine:

      system.file_allocate.set = yes

      system.method.insert=checkdirs1,simple,"not=\"$equal={d.get_custom1=,d.get_base_path=}\""
      system.method.insert=movecheck1,simple,"and={checkdirs1=,d.get_complete=,d.get_custom1=}"
      system.method.insert=movedir1,simple,"d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_cust$
      system.method.set_key=event.download.hash_done,move_hashed1,"branch={$movecheck1=,movedir1=}"

  5. Kalliman

    Hi,

    I’m trying to get over the problem that I encounter.
    First of all, I had some issues with the adress of libtorrent and rtorrent packages.
    This could be resolved by using the commands
    sudo wget https://github.com/rakshasa/libtorrent/archive/0.13.4.tar.gz -O libtorrent-0.13.4.tar.gz
    and
    sudo wget https://github.com/rakshasa/rtorrent/archive/0.9.4.tar.gz -O rtorrent-0.9.4.tar.gz
    in 5.1. and 5.2. steps.

    For now, I’m blocked at step 11, where the response does not show SCGI listening.

    I must have something wrong, but I tried a lot of things and did not found anything yet. I google some informations about rtorrent and rutorrent configuration, but cannot figure what I have to do to have it to work….

    BTW, the last but least system command is not complete : there is missing a lot in it :
    system.method.insert=movedir1,simple,”d.set_directory=$d.get_custom1=;execute=mv,-u,$d.get_base_path=,$d.get_custom1=;d.set_custom1=;d.stop=;d.start=”
    (information here : https://wiki.archlinux.org/index.php/RTorrent#Manage_completed_files

    Any help would be appreciated !

    K.

    1. sethuper

      Thanks.
      I have fixed links to rtorrent download and step 11 – try now, and remove from rtorrent.rc ,system.file_allocate.set ,system method ….. it was for testing but i don’t have time to check it.

Leave a Reply

Your email address will not be published. Required fields are marked *