«

»

Jan 27

How to Install and Configure: ruTorrent, rTorrent, Libtorrent, XMLRPC, Screen (Ubuntu)

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 libssl-dev

 

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. Install 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. Install rTorrent.

5.1. Install 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. Install 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

 

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

sudo nano /opt/rtorrent/.rtorrent.rc
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:

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/

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
...

 

Access to ruTorrent WebUI.

Edit /etc/apache2/sites-available/000-default.conf and add infoformation about files and locations secured by password apache2.

sudo nano /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/

    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>


    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>

    

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

 

Create configfile /etc/apache2/sites-available/rutorrent.

sudo nano /etc/apache2/sites-available/rutorrent
# ruTorrent
#===========================================================================

<VirtualHost *:80>
        DocumentRoot /var/www/rutorrent/
        ErrorLog /var/log/apache2/error.log
        CustomLog /var/log/apache2/access.log combined
</VirtualHost>

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

 

Enable ruTorrent configfile:

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

 

Add server name to configfile eg: localhost (at the bottom).

sudo nano /etc/apache2/apache2.conf
ServerName localhost

 

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}

 

Create new username password for SCGI.

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

 

Link folder passwords-available to passwords-enabled to enable configfile with password.

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

 

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

sudo nano /etc/apache2/sites-available/rtorrentscgi
#rTorrent SCGI Password Location
#===========================================================================
        <LocationMatch "/RPC2">
                AuthType        Basic
                AuthName        "rtorrentscgi"
                AuthUserFile    /etc/apache2/passwords-enabled/rtorrentscgi
                Require         valid-user
                BrowserMatch    "MSIE"  AuthDigestEnableQueryStringHack=On
                Order           allow,deny
                Allow From      all
        </LocationMatch>
#===========================================================================

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

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

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

 

Enable rtorrentscgi configfile:

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

 

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

 

Output..

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

 

12. rTorrent Autostart script.

Download script and save it to /etc/init.d/.

sudo wget http://terminal28.com/wp-content/uploads/2014/07/rtorrent -O /etc/init.d/rtorrent

 

Edit script and chanage option user to rtorrent.

sudo nano /etc/init.d/rtorrent
...
user="rtorrent"
...

 

Change permission and start rTorrent.

sudo chmod +x /etc/init.d/rtorrent
sudo update-rc.d rtorrent defaults
sudo /etc/init.d/rtorrent start

 

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

Commands:

sudo /etc/init.d/rtorrent start       - start rtorrent
sudo /etc/init.d/rtorrent stop        - stop rtorrent
sudo /etc/init.d/rtorrent restart     - restart rtorrent

 

13. 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/

 

rutorrent

39 comments

Skip to comment form

  1. andy

    Hi,

    installed step for step, but opened rutorrent in the browser: “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”. (Ubuntu 14.04.2).

    1. sethuper

      I just tested this tutorial on Ubuntu 14.04.2 (Desktop) and there is no problem at all.
      “No connection to rTorrent.” it means that rtorrent is not running.

      sudo /etc/init.d/rtorrent start

      Pay more attention when you copy and paste this tutorial.

  2. andy

    netstat says, that rtorrent is running, but not on 127.0.0.1:5000. Port is correct in config.php and rtorrent config-file. Why there is no connection to localhost?

    1. sethuper

      I didn’t say anything about configuring config.php.
      You missed some Apache2 configuration.

      Here is logfile for Apache2, it will show errors about connection:

      /var/log/apache2/access.log
      /var/log/apache2/error.log

  3. Martin

    Hello, thank you for your guide.

    I downloaded and installed your init script. It works if invoked manually with sudo /etc/init.d/rtorrent start, but rtorrent is not running after reboot.
    There are no errors in the log file, only my debug messages I’ve put in there to see which functions are invoked. During boot, checkcnfg and d_start are invoked, but rtorrent is not running.

    1. sethuper

      After some updates, there is sometimes problem with shutting down rtorrent, all you need to do is to remove this file: rtorrent.lock and run rtorrent again:

      sudo rm -fr /opt/rtorrent/session/rtorrent.lock
      sudo /etc/init.d/rtorrent start

      or reboot

      sudo rm -fr /opt/rtorrent/session/rtorrent.lock
      sudo reboot

      1. Martin

        Nope, that’s not it. That file doesn’t exist.

        I have created my own short script and added it to init.d, the log shows that it runs during the boot, but it doesn’t show up in netstat.

        In the end, I’ve added a line to /etc/rc.local: sudo -H -u rtorrent bash -c ‘screen -fa -d -m rtorrent’
        And after the reboot, netstat reports rtorrent is running and also rutorrent works.

        1. sethuper

          Try to copy your rtorrent.rc config to root directory and see what happens.

          sudo cp /opt/rtorrent/.rtorrent.rc /root

          kill then run rtorrent again.

          or you can try run rtorrent like this:
          Log in as user rtorrent:

          su - rtorrent
          rtorrent

        2. strathos

          I struggled with the same scenario, and I think I found the answer. The init script doesn’t have networking as a requirement. So modify the info part of your init script to match:
          ### BEGIN INIT INFO
          # Provides: rtorrent
          # Required-Start: $local_fs $remote_fs $network $syslog
          # Required-Stop: $local_fs $remote_fs $network $syslog
          # Default-Start: 2 3 4 5
          # Default-Stop: 0 1 6
          # Short-Description: Start daemon at boot time
          # Description: Enable service provided by daemon.

          This worked at least for me in exactly the same situation (manually worked, but not on boot).

          1. sethuper

            Well, I never had problem with this script, but i will update it just to make sure that there will not be any problems with it in the future..

            Thank You.

          2. Marco Lourenço

            I think it’s not working again. I can start it manually but not with the provided script at startup. I’m using Ubuntu 14.04.2. I’m trying to debug it, but it’s not easy.

          3. sethuper

            Sorry I can’t check it and tell you will it work stable.
            Disable rtorrent init script and try script for systemd from this tutorial:
            http://terminal28.com/how-to-install-and-configure-rutorrent-rtorrent-libtorrent-xmlrpc-screen-debian-8-jessie/#13_Autostart_rTorrent_8211_systemd

          4. Marco Lourenço

            Following your idea of not using init.d, I used an old upstart script for Deluge daemon and converted it for rtorrent :

            start on filesystem and static-network-up
            stop on runlevel [016]

            respawn
            respawn limit 5 30

            exec start-stop-daemon –start –chuid rtorrent –name rtorrent –exec /usr/bin/dtach — -n /tmp/rtorrent.dtach /usr/local/bin/rtorrent

            This goes in /etc/init/rtorrent.conf. I used a start-stop-daemon call from someone else, so it is using dtach instead of screen, which is not a big deal. Hope it helps someone, it worked for me at least.

          5. Marco Lourenço

            Well, it stopped working again, don’t know why. I’ve already tried all script results for init.d and upstart from Google search.

            Finally, because I also had some problems with ddclient and OpenVPN at startup, problems that I solved with a “sleep 60” for the ddclient startup script, I randomly applied the same strategy here.

            I added a “sleep 30” to the startup script of rtorrent (I know it’s ugly) and now the script does start rtorrent correctly. I think screen is not available for whatever reason when the script tries to launch the screen command. Because it seemed to work previously, maybe screen has changed something in it’s behaviour or maybe it’s juste my server having problems.

            If anyone running Ubuntu 14.04 has no problems with the script provided in this tutorial, I guess it’s my computer, but really couldn’t tell why. Anyway, hope the “sleep hack” can help someone one day…

  4. Malin Cenusa

    Tested it on Ubuntu 15.04 (Vivid Vervet) and works flawlessly.

  5. slapper

    Also tested on 15.04 and works awesome. Great job!

    It is great that this comes up near the top of the results when you query for rtorrent guides.

    One thing I would recommend is to do the ruTorrent 3.7 via git clone instead of downloading the zip. This way you just do “git pull” in the directory in the future to keep in sync with Novik’s ruTorrent git

    sudo git clone https://github.com/Novik/ruTorrent.git /var/www/rutorrent/

    1. sethuper

      Here you are
      ..8.1. ruTorrent via GIT.

  6. Janik

    Hey There,
    unfortunately I can not download from rakshasa.no, the site is offline?

    Is there an alternative download, or has anyone the files?

    Have attempts https://github.com/rakshasa/libtorrent and https://github.com/rakshasa/rtorrent, but this does not work the make. It’s not a make file available.

    Regards Janik

    1. sethuper

      Server is down.

      1. Janik

        When will he be back online? Is there an alternative download?

        1. sethuper

          I dont know, its unusual..
          Use git instead:
          sudo git clone https://github.com/Novik/ruTorrent.git /var/www/rutorrent/

  7. slapper

    Yes it is known problem about the site. I found it in bug report https://github.com/rakshasa/rtorrent/issues/295#issuecomment-120936501 (read the comments at the end)

    It is there I also found that

    LibTorrent 0.13.5 and rTorrent 0.9.5 has been tagged and released 2 weeks ago !!

    https://github.com/rakshasa/libtorrent/archive/0.13.5.tar.gz

    https://github.com/rakshasa/rtorrent/archive/0.9.5.tar.gz

    Time to update the guide 🙂

    1. sethuper

      I will do it soon, now I fight with CCTV Zoneminder..

  8. Robert

    Thanks for the excellent guide! I had tried setting up ruTorrent on my own using the packages available in Utopic (libtorrent14 and rtorrent 0.9.2), but needed some help with the htaccess/SCGI part. When I still failed to make it work properly, I used the exact method stated here, and it now works like a charm!

  9. Robert

    Just a quick note; I remembered a couple of things I had to do on Ubuntu 14.10 (and replicated on 15.04) slightly differently from the guide. Mileage may vary on these as I was working with pretty bare-bones server installations, and a standard installation might have some or all of these already.

    I had compilation errors with xmlrpc-c that I didn’t feel like trying to resolve. So, instead of step 4:
    sudo apt-get install libxmlrpc-c++8 libxmlrpc-c++8-dev

    I also got an error (missing libcrypto) when configuring libtorrent. Before step 5:
    sudo apt-get install libssl-dev

    Other than that, the guide was flawless. Although, I should mention that both times I left the .rtorrent.rc in /opt/rtorrent instead of the user’s home directory, and wondered why the SCGI port wasn’t working! If it was my guide, I’d put “~/.rtorrent.rc” in that command instead, but that’s just me; anyone who’s actually READING the thing would know what to do. 😛

    Thanks again for this very useful guide!

    1. sethuper

      I did this tutorial on Ubuntu 14.10 long time ago..
      Added libssl-dev.
      Yes you are right, if you configure rtorrent.rc for your own user..
      nano ~/.rtorrent.rc
      but in this case you create seperated user just for rtorrent.
      To edit the way you have done it, you have to login as user rtorrent:
      su - rtorrent
      then
      nano ~/.rtorrent.rc

      Thank you for info.

  10. Hello

    Thank you for the tutorial! BTW, what’s your Apache version for this tutorial? For some new Apache versions, it has /var/www/html, not /var/www. I’m not sure if this tutorial works for /var/www/html, anything to modify if Apache is the version? Like 2.4.7.

    Thank you!

    1. sethuper

      It was long time ago when i tested this tutorial, but if default configuration of apache2 (2.4.7) is /var/www/html at this moment then replace /var/www to /var/www/html or make alias:
      Alias /rutorrent /var/www

      <Directory /var/www>
      Options +Indexes +Includes +FollowSymLinks +MultiViews
      AllowOverride all
      Require all granted
      </Directory>

  11. ScaryCat

    followed the guide works for r/rutorrent some other things failed..doesnt bother me! but it doesnt ask for password to webGUI what did i miss??

    1. sethuper

      You need to tell me what kind of things failed.
      It could be a reason why password for rutorrent doesn’t work.

  12. nikos

    Hi, I did everything mentioned but rtorrent doesn’t work. How can I delete the whole process so I start it from scratch?

    1. sethuper

      What do you mean that rtorrent doesnt work? does it start at all? Is compilation failed?
      You do not need to remove whole process of the installation if one has failed…
      Let me know where the proces failed the i will sort it out for you cos you are not the first who got problem with the instalation after when ubuntu got some new updates…

      1. nikos

        I had a problem when configure with xmlrpc-c which I ignored. I start rtorrent, but rtorrent doesn’t show up with netstat. When I go to http://127.0.0.1/rutorrent I get the usual error “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.” I did check for scgi if is configured correct and it is. I did follow carefully step by step the guide.
        I have Ubuntu 15.04 with latest updates

        1. sethuper

          ok then you have to uninstall rtorrent installation. got to install folder:
          cd install
          then to rtorrent folder
          cd rtorrent-0.9.4
          and uninstall rtorrent:
          sudo make uninstall
          and again got to libtorrent folder:
          cd ..
          cd libtorrent-0.13.4
          and uninstall libtorrent:
          sudo make uninstall
          then you can compile and install everything again, dont forget about xmlrpc.

  13. nikos

    I cant reply. rtorrent/libtorrent gives error “nothing to be done” and xmlrpc gives error: no rule to uninstall

    1. sethuper

      So rtorrent and libtorren’t wasnt installed then just compiled.
      Compile rtorrent again with xmlrpc this time..

  14. nikos

    I don’t know why I can’t reply anymore, rtorrent/libtorrent still give error: nothing to be done when I try make install. Same thing happened with xmlrpc that gives error: error no 2

    1. sethuper

      I found temporary solution.
      Do not compile xmlrpc-c. Skip this step and install these 2 packages instead:
      sudo apt-get install xml2-dev libxmlrpc-c++8-dev
      Then compile libtorrent and rtorrent..
      If you will get any error while compiling libtorrent, configure it again like this:
      ./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server --disable-cplusplus
      Just tested under Ubuntu 15.10 Desktop (64bit).

  15. nikos

    No, it doesn’t work onto my system. http://i.imgbox.com/ciydlqBi.png

Leave a Reply

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