How to Install and Configure: ruTorrent, rTorrent (Debian 9 Stretch).

Add your username to /etc/sudoers.


Root password.

apt-get install sudo
nano /etc/sudoers


joe         ALL=(ALL) ALL

Adding unrar to the APT list.

sudo nano /etc/apt/sources.list

Add these: main contrib non-free at the end of each link line e.g.

deb stretch-backports main contrib non-free

then update, upgrade and install unrar

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install unrar

1. Create new user “rtorrent” and home directory.

home directory: /opt/rtorrent.

Debian 9.5+.

sudo adduser --disabled-login --disabled-password --home /opt/rtorrent --system rtorrent

Debian 8-9.

sudo adduser -s /sbin/nologin --home /opt/rtorrent rtorrent

2. Update system/server.

sudo apt-get update
sudo apt-get upgrade

3. Install some needed dependencies: Apache2, PHP7 etc.

sudo apt-get -y install php php-geoip php7.0-cli php7.0-json php7.0-curl php7.0-cgi php7.0-mbstring libapache2-mod-php libapache2-mod-scgi libapache2-mod-xsendfile apache2 unrar unzip libav-tools ffmpeg mediainfo curl screen sqlite3 git net-tools sox

4. Install rtorrent.

sudo apt-get -y install rtorrent libtorrent19 libxmlrpc-core-c3

5. Create 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}

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

Default directory: /opt/rtorrent/.

sudo wget --no-check-certificate -O /opt/rtorrent/.rtorrent.rc
sudo chmod 777 /opt/rtorrent/.rtorrent.rc

Example .rtorrent.rc:

# Port SCGI
scgi_port = localhost:5000

#This is an example resource file for rTorrent. Copy to

# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.

# Maximum and minimum number of peers to connect to per torrent.
throttle.min_peers.normal.set = 40
throttle.max_peers.normal.set = 100

# Same as above but for seeding completed torrents (-1 = same as downloading)
throttle.min_peers.seed.set = 10
throttle.max_peers.seed.set = 100

# Maximum number of simultanious uploads per torrent.
throttle.max_uploads.set = 15

# Global upload and download rate in KiB. "0" for unlimited.
throttle.global_down.max_rate.set_kb = 0
throttle.global_up.max_rate.set_kb = 8

# Default directory to save the downloaded torrents.
directory.default.set = /opt/rtorrent/download

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session.path.set = /opt/rtorrent/session

# Watch a directory for new torrents, and stop those that have been
# deleted.
schedule2 = watch_directory,5,5,load_start=/opt/rtorrent/session/*.torrent
schedule2 = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low.
schedule2 = low_diskspace,5,60,close_low_diskspace=2000M

# The ip address reported to the tracker.
#network.local_address.set =
#network.local_address.set =

# The ip address the listening socket and outgoing connections is
# bound to.
#network.bind_address.set =
#network.bind_address.set =

# Port range to use for listening.
network.port_range.set = 6890-6999

# Start opening ports at a random position within the port range.
network.port_random.set = no

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
pieces.hash.on_completion.set = no

# Set whether the client should try to connect to UDP trackers.
trackers.use_udp.set = yes

# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule2 = ip_tick,0,1800,ip=rakshasa
#schedule2 = bind_tick,0,1800,bind=rakshasa

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
dht.mode.set = auto

# UDP port to use for DHT.
dht.port.set = 6881

# Enable peer exchange (for torrents not marked private)
protocol.pex.set = yes

# Set downlad list layout style. ("full", "compact")
#ui.torrent_list.layout.set = "full"

7. Install and configure ruTorrent.

7.1. ruTorrent via GIT.
sudo git clone /var/www/rutorrent/
sudo chown -R www-data:www-data /var/www/rutorrent
7.2. ruTorrent mobile.

Acces to ruTorrent, rTorrent from Apple smartphones and older smartphones.

Acces to ruTorrent, rTorrent from Android smartphones.

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.

Some apps might not be in default location.
Use whereis app to find binary files and then update lines in config file. See below.

whereis gzip
gzip: /bin/gzip /usr/share/man/man1/gzip.1.gz /usr/share/info/
$pathToExternals = array(
"php" => '/usr/bin/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" => 'bin/gzip', // Something like /usr/bin/gzip. If empty, will be found in PATH.
"id" => '/usr/bin/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.

8. Install GeoIP database.

sudo gunzip GeoLiteCity.dat.gz
sudo mkdir -v /usr/share/GeoIP
sudo mv -v GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat

9. Secure ruTorrent web access.

Create the .htpasswd file.

cd /var/www/rutorrent
sudo htpasswd -c /var/www/rutorrent/.htpasswd nazwa_użytkownika

You will be asked for a password twice.


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

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


Enable ruTorrent WebUI.

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

11. Activate Apache2 modules.

sudo a2enmod auth_digest
sudo a2enmod authn_file
sudo a2enmod xsendfile
sudo a2enmod scgi

12. Secure SCGI (/RPC2) directory.

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 username

Enable rtorrentscgi password.

Link folder passwords-available to passwords-enabled.

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

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
                Require         valid-user
                BrowserMatch    "MSIE"  AuthDigestEnableQueryStringHack=On
                Require ip


#LoadModule scgi_module /usr/lib/apache2/modules/


Enable rtorrentscgi config.

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

Restart Apache2 server.

sudo service apache2 restart

13. Autostart rTorrent – systemd.

Create rtorrent autostart script for systemd.

sudo nano /etc/systemd/system/rtorrent.service

ExecStartPre=-/bin/rm -f /opt/rtorrent/session/rtorrent.lock
ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent


Enable rTorrent autostart..

sudo systemctl enable rtorrent.service

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


sudo service rtorrent start       - uruchamianie
sudo service rtorrent stop        - zatrzymywanie
sudo service rtorrent restart     - restart


sudo systemctl start rtorrent     - uruchamianie
sudo systemctl stop rtorrent      - zatrzymywanie
sudo systemctl restart rtorrent   - restar

14. Start service rTorrent.

sudo service rtorrent start

Testing rTorrent:

sudo netstat -npl | grep rtorrent


tcp    0 0*    LISTEN 16229/rtorrent
tcp    0 0*    LISTEN 16229/rtorrent
udp    0 0*    16229/rtorrent

Access to your web front-end for rTorrent.

http://IP address/rutorrent



You should be asked for username and password to access website



Skip to comment form

    • Eduardo on 13 September 2018 at 03:45

    great tutorial, thanks
    works on ubuntu 16.04, with a minor correction to “adduser” command: sudo adduser –home /opt/rtorrent –disabled-login rtorrent

      • sethuper on 4 February 2019 at 20:49

      Thank you.

    • NA on 14 October 2018 at 20:28

    E: Package ‘unrar’ has no installation candidate

      • sethuper on 14 October 2018 at 20:38

      unrar is non-free version, you have to change settings in nano /etc/apt/sources.list to get it..

    • GRAEME on 29 October 2018 at 15:55

    im on Debian 9 but the first command to adduser dont work

    sudo adduser -s /sbin/nologin –home /opt/rtorrent rtorrent

    and i get

    Option s is ambiguous (shell, system)

      • sethuper on 4 February 2019 at 20:36

      Thank you.

    • Ns on 9 November 2018 at 14:42

    Nice job! As clear as the Debian 8 version 🙂

    Thanks for sharing,

    • Ns. on 29 November 2018 at 12:45


    Thank you for your work!

    Question: I get several errors when i add torrent like:
    – Tracker: [Timeout was reached]
    – Tracker: [Timeout was reached]

    for information rtorrent is running inside a Vhost ( proxmox CT)


      • sethuper on 4 February 2019 at 20:35

      maybe tracker down or connection problem?

    • nS. on 4 February 2019 at 14:55


    Thanks a lot for your work!

    Just one thing in point 12:

    AuthUserFile /etc/apache2/passwords-enabled/rtorrentscgi

    should be :

    AuthUserFile /etc/apache2/passwords-enabled/rtorrent

    isn’t it ? because of the link name.

    Last point: Could you please explain us how to add an new user with your configuration ?


      • sethuper on 4 February 2019 at 20:32

      Fixed it.
      Thank you.

      Adduser command has some change, so its fixed.

      sudo adduser --disabled-login --disabled-password --home /opt/rtorrent --system rtorrent

      and symlink fixed as well

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

      AuthUserFile /etc/apache2/passwords-enabled/rtorrentscgi

    • IFFI on 25 June 2019 at 17:21


    Thanks a lot for your work! But how to change upload speed limit? Current speed max 8kb/s


    1. edit .rtorrent.rc
      throttle.global_up.max_rate.set_kb = 100
      (100 kilobytes e.t.c)

      or you can change it in rutorrent:
      klick on blue sprocket icon > Connection tab > Global maximum upload rate and set there in kilobytes

    • Bajza Ferenc on 13 July 2019 at 19:45


    Thanks for this tutorial! I reproduced these steps, but I have this below error on ruTorrent:
    “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.”

    All of these settings has been set as you wrote in this tutorial, but it’s still not working. Can you help me?

    Thank you!

    1. I think there is some change in .rtorrent.rc
      sudo nano /opt/rtorrent/.rtorrent.rc
      Remove this:
      scgi_port =
      and add this:
      network.scgi.open_port = ""
      Make sure this file has been created – step 12:
      and is linked to
      Make sure these are in rutorrent’s config.php
      sudo nano /var/www/rutorrent/conf/config.php
      $scgi_port = 5000;
      $scgi_host = "";

      And make sure these packages are installed:
      libapache2-mod-scgi, libxmlrpc-core-c3

        • Bajza Ferenc on 14 July 2019 at 22:41

        Thank for this very fast reply! Unfortunately none of them helped me.
        Can I send to you my config files somehow? For example by email.


        1. Use this website to paste your configs (apache2 rutorrent, rtorrentscgi, rtorrent.rc, etc) and set expire after 1 week cos I won’t have time to check it in next few days..
          then paste links in comments.
          You can try do this tutorial again but carefully and overwrite everything. Make sure that symlinks are created. You could miss something..

            • Bajza Ferenc on 15 July 2019 at 10:03

            Okay, it was my fault. I not changed to my path the home directory of rtorrent user at the beginning. After I changed it, works well.

            Thanks for the help!

    • scouse on 26 August 2019 at 20:43

    I wonder if someone can help me I am trying to run rtorrent as either a none system user or as root, but it won’t work, is there any reason why the user needs to be a system user in order for it to run and is there any way to get around it?

    I have tried everything including changing the permissions on /opt/rtorrent and amending rtorrent.service but it still won’t work.
    Any advice would be most appreciated.

    Thanks for the great guide!!!

      • sethuper on 26 August 2019 at 22:50

      Every app on linux/unix runs with system user, there is no any non, virtual etc user.
      The easy way is to run app as user admin/root so you can run any app with no any problems.
      If you are trying to run rtorrent as root then in root folder you will have to place config file rtorrent.rc – permission for folders don’t matter.
      Root have access: read/write/exec.. to everything on the system.
      You will have to change user in rtorrent.service as well.
      Make sure you have installed everything and you didn’t miss anything from tutorial.
      Change permission to chmod 777 -R /opt/rtorrent, this should work well but everyone will have access to it.

        • scouse on 27 August 2019 at 21:16

        That worked perfectly, thanks very much…

    • Aris on 23 October 2019 at 10:31

    hello,i want to install rutorrent,but i want to use an existing external hard drive.How can i add the directories and give them permissions./media/USBDisk1/shares/completed is my download files directory,thanks

      • sethuper on 25 October 2019 at 06:24

      go to Update path to Download directory. in tutorial.
      sudo nano /var/www/rutorrent/conf/config.php
      and change this line:
      $topDirectory = '/media/USBDisk1/shares/completed'; // Upper available directory. Absolute path with trail slash.
      then change permission to files and folders:
      sudo chmod 777 -R /media/USBDisk1/shares/completed && sudo chown rtorrent:rtorrent -R /media/USBDisk1/shares/completed

Comments have been disabled.