Installing rtorrent + ruTorrent on Ubuntu Server 10.04 LTS
First things first. To give credit where it’s due, I have to link to sharky’s tutorial at filesharefreak.com. Much of my tutorial is copied from there, with a few changes to include my own personal preferences as well as a few fixes that I had to implement for my particular setup.
There’s no question that for Linux users, rtorrent is a fantastic lightweight bittorrent client. But, if you’re like me, you prefer a nice web user interface (WebUI) for your rtorrent as opposed to its not-user-friendly text interface. That’s where ruTorrent comes in. It closely mimics uTorrent’s user interface, and is therefore very user-friendly and very welcoming to Windows users looking to switch to Linux for their torrenting.
Step 1: Accessing Your Server
Should be obvious, but I feel I should include it anyway. If you have a monitor and keyboard connected to your server, of course you can use them. Just log in and proceed to Step 2. Otherwise, you’ll need a way to access your server remotely, be it from across the house or further.
If you’re installing Ubuntu Server, you have an option to install a Secure Shell (SSH) server during the install process. That’s easiest. But if you’ve installed Debian or Ubuntu’s desktop version, you will need to install it (sudo aptitude install openssh-server ) if you haven’t already. Then it’s just a matter of connecting to your server using a program like Putty if you’re in Windows. Mac OS X and Linux have SSH built-in, so you can just run it from a command line (ie.ssh <ipaddress> ).
Step 2: Install Necessary Packages
In order to use rtorrent with ruTorrent, you’ll need to install a web server as well as ensure that a few dependencies are met and some tools to compile rtorrent (don’t be scared, it’ll work better, and I’ll explain why in Step #3). I use Apache web server, some will use lighttpd. I only chose Apache because my server also serves as a test platform for other web projects (ie. this site and the others listed under “Web Portfolio”) in addition to ruTorrent.
I prefer to install packages via the command line (again, don’t be scared, I’ll explain below) in Linux, especially when I have multiple packages to install, as is the case here.
First, make sure you have a list of current versions of packages in the repositories: sudo aptitude update
When that’s finished, you’re ready to start installing tools, dependencies and the other packages needed to run your server. First, let’s make sure we have all of the packages that rtorrent will depend on: sudo build-dep rtorrent
Now we can install the tools to compile rtorrent and the Apache web server we’ll use to access the ruTorrent WebUI: $sudo aptitude install -y build-essential pkg-config libcurl4-openssl-dev libsigc++-2.0-dev libncurses5-dev screen subversion libterm-readline-gnu-perl php5-cgi apache2-server apache2-utils libapache2-mod-scgi
Where "-y" means that the package manager, Aptitude, will assume the answer will be "yes" instead of asking for confirmation that you want to install these packages. See that list of packages? It’s much easier to type out on the command line than to search and check them off in the Software Center, no? Alright, that’s done.
Step 3: Compile rtorrent
Okay, if using the command line is off-putting, then this is where Linux neophytes get scared. For those that really don’t want to compile from source, you don’t have to. You can skip Step #1, install Apache and rtorrent from the Ubuntu Software Center and skip ahead to configure ruTorrent and Apache. And it’ll pretty much work. But your mileage may vary because the version of rtorrent in Ubuntu’s (and Debian’s) repositories is compiled with an older version of xmlrpc-c. You’ll get a warning in ruTorrent informing you of this, and in my case, file sizes of torrents and their files (and, by extension, amount downloaded, uploaded, rate and ratio) were not being displayed correctly. So, you’ve been warned.
Now, let’s compile rtorrent and its components. First, libtorrent: cd /tmp
sudo wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.6.tar.gz
sudo tar zxfv libtorrent-0.12.6.tar.gz
cd libtorrent-0.12.6
sudo ./configure
sudo make
sudo make install
So what’s that mean? Well, in the first line we navigate to a temporary directory, /tmp. Then we download the source code for libtorrent, extract it, enter the directory containing the extracted files, and the last three lines are where we actually compile and install the application.
Pretty much the same deal for xmlrp-c: cd /tmp
sudo svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c
cd xmlrpc-c/
sudo ./configure
sudo make
sudo make install
Great. That’s done. On to rtorrent: cd /tmp
sudo wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.6.tar.gz
sudo tar zxfv rtorrent-0.8.6.tar.gz
cd rtorrent-0.8.6
sudo ./configure --with-xmlrpc-c
sudo make
sudo make install
That wasn’t so bad, was it?
Step 4: Configure rtorrent
Like most Linux applications, rtorrent is configured with a simple plain-text file. So we’ll have to create that file, and fill it with the requisite settings. To do that, navigate to the home folder of the user that will be running rtorrent (some create a separate user for this, I found it to be more trouble than it was worth and just run it under my own account now, but this is up to you). If you’re logged in as that user, simply typing “cd” at the command line will suffice.
So, once we’re in the home directory, we’ll have to create and open the file for editing. This can be done in one step with Debian and Ubuntu’s default text editor, nano: nano .rtorrent.rc
Now that the file’s loaded up and ready for editing, let’s get some settings in there. “Chris” is the user that will run rtorrent; edit as necessary for your situation, and do the same for your directories, creating directories as needed (ie. mkdir .rtorrent/session downloads): directory = /home/chris/downloads
scgi_port = localhost:5000 #Important - we need this for ruTorrent to work
session = /home/chris/.rtorrent/session
schedule = low_diskspace,5,60,close_low_diskspace=100M
port_range = 51515-61234
port_random = no
use_udp_trackers = no
encryption = allow_incoming,try_outgoing
dht = off
peer_exchange = no
#The Following Are VERY Important
encoding_list = UTF-8
scgi_local = /tmp/rpc.socket
schedule = chmod,0,0,"execute=chmod,777,/tmp/rpc.socket"
My settings are pretty basic, but there’s a lot you can do with your configuration file. Check out this page if you’d like to find out how to automatically move files upon completion, change permissions, set up watch directories, and so on. It’s all up to you.
Great, that’s done. You have a fully-functional rtorrent that you can run now. But we want a WebUI, so…
Step 5: Setting up ruTorrent
First, download it. Second, we’ll have to edit it so that it can find and connect to rtorrent. cd /var/www/rutorrent/conf
nano config.php
Now look for the line “$scgi_port = 5000;” and also take note of the following line: “$XMLRPCMountPoint = "/RPC2".” These are vital for allowing ruTorrent to communicate with rtorrent. The values in ruTorrent’s config.php must match up with the values in rtorrent’s configuration file above and in Apache’s configuration. Which brings us to…
Step 6: Apache
Not a whole lot to do here, we just need to make sure that Apache can allow ruTorrent to connect to rtorrent, and it is also wise to password protect your rutorrent directory on the web server.
So, we’ll navigate to Apache’s configuration files and configure them: cd /etc/apache2
sudo nano httpd.confSCGIMount /RPC2 127.0.0.1:5000
<directory /var/www/rutorrent/>
AuthName "Log In"
AuthType Basic
AuthUserFile /home/chris/.htpasswd
AuthGroupFile /dev/null
require user chris
</directory>
The First line was referenced in the last paragraph of Step #5. Those numbers need to match those in rtorrent’s .rtorrent.rc and ruTorrent’s config.php. You can change them as you see fit (that is /RPC2 can be changed to /RPCx, where x is a positive integer, and the port number can be changed from 5000; in typical practice this would be changed to 5001, or 5002, etc.), but make sure you do it across the board.
The lines below deal with security; password-protecting the rutorrent directory on your web server. For this to work, you will need to create the .htpasswd file referred to in line 5. You can do this simply by running the htpasswd command: htpasswd -c /home/chris/.htpasswd chris
For more information on htpasswd, visit Apache.org.
Next, we’ll have to make sure that SCGI is enabled in Apache, to do this, we simply need to copy it to the correct location: sudo cp mods-available/scgi.load mods-enabled/scgi.load
and restart Apache: sudo /etc/init.d/apache2 restart
That’s it! To run rtorrent, simply type “screen rtorrent” at the command line. Screen is used so that you can close your SSH session (or continue to use it for something else) while keeping rtorrent running in the background. For the latter, simply hold “Ctrl” and then hit the “A” and “D” keys in that order (Ctrl+A+D). rtorrent will disappear but continue to run, to verify this, you can simply type “screen –R” to get it back. Or, of course, you can verify with your ruTorrent WebUI by typing “http://<server-address-here>/rutorrent” in a web browser.
I’ve had success installing rtorrent on Ubuntu 10.04 Server 32-bit and 64-bit with this method. I’ve had less success with this version of rtorrent on Debian, so no guarantees that it’ll work.
I believe this guide is complete, but if you do see any omissions, typos, or if you have anything else to contribute, please leave a comment.
Enjoy!












