Tuan-Anh Tran

How to setup rtorrent, rutorrent on Ubuntu

Posted on January 4, 2015  •  3 minutes  • 556 words

This is a simple and concise tutorial on how to setup a seedbox running rtorrent with rutorrent as webui on Ubuntu OS. I’ve tried to simplify as much as possible to make it easy to understand. It may look a bit lengthy but it’s copy-paste-fu mostly.

Initial server setup

Login to your server and create a new user account, add it to sudo group. Substitute USER_NAME with your desired username.

ssh root@YOUR_SERVER_IP_ADDRESS
adduser USER_NAME
gpasswd -a USER_NAME sudo

Setup key authentication

It’s better, less hassle and a lot safer. You should use it.

# at your local machine: gen key and upload it to your vps
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub | ssh USER_NAME@YOUR_SERVER_IP_ADDRESS 'cat >> .ssh/authorized_keys'

You can try logging in your server with the new user. It will not ask you to enter password this time.

Disable root login

Use nano to change PermitRootLogin to no. Ctrl+O to save and Ctrl+X to quit afterward.

nano /etc/ssh/sshd_config
service ssh restart

Setup rtorrent

# install libraries required to build rtorrent
sudo apt-get update
sudo apt-get install subversion build-essential automake libtool libcppunit-dev libcurl3-dev libsigc++-2.0-dev unzip unrar-free curl libncurses-dev libxml2-dev

# download source and install
cd ~
mkdir src
cd src
svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc
cd xmlrpc
./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server --disable-cplusplus
make
make install

Install libtorrent

cd ~
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.4.tar.gz
tar xvf libtorrent-0.13.4.tar.gz
cd libtorrent-0.13.4
./autogen.sh
./configure --prefix=/usr
make
make install

Install rtorrent

cd ~ # back to home
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.4.tar.gz
tar xvf rtorrent-0.9.4.tar.gz
cd rtorrent-0.9.4
./autogen.sh
./configure --prefix=/usr --with-xmlrpc-c
make
make install
ldconfig

Create new user to run rtorrent and required folders

useradd -d /home/rtorrent_usr/ rtorrent_usr
mkdir /home/rtorrent_usr
mkdir /home/rtorrent_usr/downloads
mkdir /home/rtorrent_usr/.session
mkdir /home/rtorrent_usr/watch
mkdir /home/rtorrent_usr/.sockets
touch /home/rtorrent_usr/.sockets/rpc-socket
nano /home/rtorrent_usr/.rtorrent.rc
# update permission
chown -R rtorrent_usr:rtorrent_usr /home/rtorrent_usr/
chown -R www-data:www-data /usr/share/nginx/html

For rtorrent config, you can copy the default one and mess around. It’s simple and straight forward. I won’t go into details here.

cp /usr/share/doc/rtorrent/rtorrent.rc ~/.rtorrent.rc

Setup nginx/rutorrent for webui

Install nginx and php5-fpm to run rutorrent

sudo apt-get install nginx php5-fpm php5-cli

By default, your root folder will be at usr/share/nginx/html.

Create a configuration file for rutorrent

nano /etc/nginx/sites-available/rutorrent

Copy and paste the content below

server {
  listen   80;
  listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

  root /usr/share/nginx/html;
  index index.php index.html index.htm;

  server_name localhost;

  location / {
    try_files $uri $uri/ /index.html;
  }

  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
    root /usr/share/nginx/html;
  }

  # php5-fpm
  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    # With php5-fpm:
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
  }
}

Create symlink to sites-enabled and restart nginx

cd /etc/nginx/sites-enabled
ln -s ../sites-available/rutorrent
# restart nginx
service nginx restart

Create a test file to verify php5-fpm is working

nano /usr/share/nginx/html/info.php
# use content below 
<?php
  phpinfo();
?>

Download rutorrent

cd /usr/share/nginx/html
svn checkout http://rutorrent.googlecode.com/svn/trunk/rutorrent
svn checkout http://rutorrent.googlecode.com/svn/trunk/plugins
rm -r rutorrent/plugins
mv plugins rutorrent/

And that’s it. Start rtorrent and things should work as it supposes to. Feel free to ask me any question if you got stuck.

If you’re a casual torrent user like me and still looking for a dead-cheap, torrent-friendly VPS provider, I may recommend you to take a look at RamNode . They provide a $15 per YEAR for 80GB of space and 500GB bandwidth. As long as you don’t do heavy torrenting and public trackers, you should be safe.

Cheers!

Follow me

Here's where I hang out in social media