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….
1 2 3 4 |
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.
1 2 3 4 |
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.
1 2 3 4 5 |
git clone https://github.com/mirror/xmlrpc-c.git cd xmlrpc-c/stable/ ./configure --disable-cplusplus make make install |
Install libtorrent
1 2 3 4 5 6 |
git clone -b feature-bind https://github.com/rakshasa/libtorrent.git cd libtorrent ./autogen.sh ./configure --disable-instrumentation make make install |
Install rTorrent
Clone and compile. We need to make sure we configure –with-xmlrpc-c.
1 2 3 4 5 6 7 |
git clone -b feature-bind https://github.com/rakshasa/rtorrent.git cd rtorrent ./autogen.sh ./configure --with-xmlrpc-c make make install ldconfig |
Install and configure ruTorrent
This one is easy. We just need to clone the git repo into /var/www
1 2 3 4 |
mkdir -p /var/www cd /var/www git clone https://github.com/Novik/ruTorrent.git chown -R www-data:www-data /var/www |
now edit the conf/config.php
1 2 3 4 5 6 7 8 9 10 11 12 |
$topDirectory = "/home/rutorrent" $scgi_port = 5000; $scgi_host = "127.0.0.1" $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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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; scgi_pass 127.0.0.1:5000; } 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”?
1 |
htpasswd -c /etc/nginx/.htpasswd rutorrent |
now delete the default settings and restart nginx and php5-fpm
1 2 |
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# ---------------------------------------------------------------------- # 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 throttle.max_uploads.global.set = 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 = 127.0.0.1:5000 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.
1 2 3 |
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
1 |
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.