Author Topic: Installing ruTorrent/rTorrent on Debian  (Read 6156 times)

0 Members and 1 Guest are viewing this topic.

Offline iTpHo3NiX

  • EZ's Pirate Captain
  • Administrator
  • Titan
  • *
  • Posts: 2920
  • Cookies: 328
    • View Profile
    • EvilZone
Installing ruTorrent/rTorrent on Debian
« on: November 26, 2010, 06:41:00 am »
Complete Step by Step Guide for Setting up ruTorrent and FTP on Debian
by iTpHo3NiX

Ok so where to start. Let's start with the Operating system. I prefer Debian which is why I decided to find the best guide, modify it, and through trial and error have come up with a complete guide that a noob can follow. This will have explanation, and everything you will need to get this working 100% I decided doing it on rTorrent/ruTorrent as it seems to be the most popular, but not the easiest installation, although it seems to look harder then it actually is. Following this guide could get you up and running within 10-15 minutes :D

NOTE: You will need PuTTY, download here

So lets get to work.

What We Will Be Doing

1. Introduction and Explanation
2. Installing Dependencies
3. Downloading Setup Files
4. Compiling
5. Making Directories
6. Authentication and SSL
7. Config Files
8. Installing ruTorrent
9. Installing Plugins
10. Installing and setting up ProFTPd (FTP Server)
11. Starting rTorrent and Getting Everything Running

Chapter 1
Introduction and Explanation

Welcome to iTpHo3NiX's guide to Installing rTorrent/ruTorrent with FTP on Debian. This will go over a complete guide on how to do this so even if you have no experience in setting up a seedbox, you can accomplish it by simply following this guide. Now I know there are 10 chapters but they are short, however I will go into detail about what we are doing to your system. I would like to go over a few commands that you should know, since I'm assuming you have little or no experience, this will make things easy.

Commands you should know

nano This command is a text editor which I find to best and easiest to work with. So whenever we need to modify a config file we will be using nano. Now to use nano you simply do the following:

Quote
nano /path/to/file/file.txt

A few notes you'll need to know is that there is a few commands within nano that will make it a whole lot easier to find what your looking for.

CTRL+W - This is "where" if you are requested to modify a certain string within a configuration file, instead of looking through it, simply type in CTRL+W and then type in part of the string and press enter. It will bring you to that part and you will be set to go

CTRL+X - This is to "exit" and save your changes. You just need to press CTRL+X and then it will ask if you for a file name, in this guide it will already have pre-defined names, so just press enter, and then it will prompt you to make sure you want to overwrite the file and press yes again.

ls - This will be used to list the folders in a directory. I tend to do this a lot just to follow what I'm doing and making sure everything is ok, but that's just me, but you should know the list command.

cd - This will be used to change directories. Pretty straight forward, but you should be familiar with it as you will be changing directories.

locate - I don't officially use this command in this guide, however sometimes config files don't always like to go to the same spot. However sometimes, it still wont find what you are looking for so if you run the command like this, you wont have a problem

Quote
updatedb && locate config.conf

Where "config.conf is replace by with what you are searching.

Right-Click - This is "paste" so when you copy a line and want to paste it in, simply just right click within the shell.

So I think with those, if you run into any issues you can find yourself around. So by now after reading my preface and introduction you'll want to get started so hold on, time to get started.

Chapter 2
Installing Dependencies

First, make sure you are logged in as root, now I know your not supposed to run rtorrent as root, but it makes everything so much easier. Now we need to update our repositories and upgrade the system.

Quote
apt-get update
apt-get upgrade

Now it's time for the dependencies. Now I'm not going to go through each one, what they are, what they do, just know that your going to need them :P

(Note: This is one line)
Quote
apt-get install apache2 apache2.2-common apache2-utils autoconf automake autotools-dev binutils build-essential bzip2 ca-certificates comerr-dev cpp cpp-4.1 dpkg-dev file g++ g++-4.1 gawk gcc gcc-4.1 libapache2-mod-php5 libapache2-mod-scgi libapr1 libaprutil1 libc6-dev libcppunit-dev libcurl3 libcurl4-openssl-dev libexpat1 libidn11 libidn11-dev libkrb5-dev libmagic1 libncurses5 libncurses5-dev libneon26 libpcre3 libpq5 libsigc++-2.0-dev libsqlite0 libsqlite3-0 libssl-dev libssp0-dev libstdc++6-4.1-dev libsvn1 libtool libxml2 linux-libc-dev lynx m4 make mime-support nano ntp ntpdate openssl patch perl perl-modules php5 php5-cgi php5-cli php5-common php5-geoip php5-sqlite php5-xmlrpc pkg-config python-scgi screen sqlite ssl-cert subversion ucf unrar zlib1g-dev

After that we need to enable some modules for apache2

Quote
a2enmod ssl && a2enmod auth_digest && a2enmod scgi

And that's the dependencies, from here on out its just compiling and setting it up.

Chapter 3
Downloading Setup Files

Ok now we need to download 3 things. One is xmlrpc-c which is the API used to have rTorrent communicate with ruTorrent. The other is libtorrent which is required for rtorrent to run, and then lastly we need rtorrent :D (don't worry, you will be downloading ruTorrent later, I didn't forget about it :P). So let us get to the commands.

Quote
svn co https://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/advanced/ xmlrpc-c
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.12.6.tar.gz
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.8.6.tar.gz
tar xzfv libtorrent-0.12.6.tar.gz
tar xzfv rtorrent-0.8.6.tar.gz

rm libtorrent-0.12.6.tar.gz && rm rtorrent-0.8.6.tar.gz

That's it, you should now have 3 folders in ~ (/root) xmlrpc-c, rtorrent-0.8.6, and libtorrent-0.12.6 You can check this by simply typing in "ls" to receive a list of what is in the current directory. So if you have those 3 folders let's continue, if not, I don't think you will be able to follow this guide. You can PM me here.

Chapter 4
Compiling

Ok this is a bunch of commands, each to be ran on their own line. Now, please note that it will take a little longer for the "make" commands, but it does get done, so don't worry its normal. So lets just jump in and get your bin files (executables).

Quote
cd xmlrpc-c
./configure --disable-cplusplus
make
make install

Quote
cd ../libtorrent-0.12.6
./configure
make
make install

Quote
cd ../rtorrent-0.8.6/
./configure --with-xmlrpc-c=/usr/local/bin/xmlrpc-c-config
make
make install

Quote
ldconfig

That's it you have them installed... Simple enough right?

Chapter 5
Making Directories

Ok its nice to do something simple after some compiling from source :P (which is what you just did) So lets make some download directories (which you will be using for the ftp as well as for rutorrent)

Quote
cd /home
mkdir rtorrent
cd rtorrent

Quote
mkdir session
mkdir watch
mkdir downloads

Quote
cd ..
chmod 777 rtorrent -R

That's it, simple, but very needed ;) So this is going to be your structure for ruTorrent.

/home/rtorrent/downloads - Your downloads directory, will also be your FTP directory
/home/rtorrent/session - This is going to be used by rtorrent which will be running, this isn't important to you, but it is to rtorrent
/home/rtorrent/watch - Any torrent files added to this folder will automatically be added to rtorrent

So that's it for making directories, time to secure your web server so only you can access it.

Chapter 6
Authentication and SSL

Ok now ruTorrent, unlike Torrentflux, doesn't come with its own authentication. So we'll need to make one. Now this will be good for a year from when you make it. It's ok, you can just run the command again to make it again and it will be fine (although I haven't seen someone stay with the same exact box for more then a year, best to change boxes every so often, idk, just my opinion, seems safer to me). So lets just jump in.

Quote
openssl req $@ -new -x509 -days 365 -nodes -out /etc/apache2/apache.pem -keyout /etc/apache2/apache.pem

Quote
chmod 600 /etc/apache2/apache.pem

Quote
htdigest -c /etc/apache2/passwords EnterPass YOUR_USERNAME

Only replace the text in red with whatever username you would like to use to log into the seedbox gui. After you run that command it will prompt you for a password which you simply put in twice and your set with security ;)

Chapter 7
Config Files

Ok now it's time to edit some config files to get everything working.

1. rTorrent config file

You will need to be in /root so type in:

Quote
cd ~

Now do

Quote
nano .rtorrent.rc
(notice the "." those ARE needed.

Paste in the following (remember right click to paste)

Quote
# This is part of iTpHo3NiX's Complete rTorrent guide from UtN
scgi_port = 127.0.0.1:5000
encoding_list = UTF-8
directory = /home/rtorrent/downloads
session = /home/rtorrent/session
schedule = watch_directory,5,5,load_start=/home/rtorrent/watch/*.torrent
port_range = 55990-56000
check_hash = no
use_udp_trackers = no
encryption = allow_incoming,enable_retry,try_outgoing
dht = disable
peer_exchange = no
# This is part of iTpHo3NiX's Complete rTorrent guide from UtN

Press CTRL+X and save. rTorrent should now be functional, but we will get to that.

2. Apache Configuration

We need to configure apache for the SSL, XMLRPC-C (SCGIMount). So here we go

Quote
cd /etc/apache2/
nano apache2.conf

Add these two lines, anywhere within (I suggest very bottom) the apache configuration file

Quote
SCGIMount /rutorrent/RPC2 127.0.0.1:5000
servername localhost

Quote
rm -f /etc/apache2/sites-available/default
nano /etc/apache2/sites-available/default

Paste the following, however be sure to add your hosts IP address where it is in red! VERY IMPORTANT! and add :// after http because I didn't want it to become a link. This is VERY VERY IMPORTANT.

Quote
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

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

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    <Location /rutorrent>
        AuthType Digest
        AuthName "gods"
        AuthDigestDomain /var/www/rutorrent/ httpyour.server.ip/rutorrent

        AuthDigestProvider file
        AuthUserFile /etc/apache2/passwords
        Require valid-user
        SetEnv R_ENV "/var/www/rutorrent"
    </Location>

</VirtualHost>

<VirtualHost *:443>
        ServerAdmin webmaster@localhost

        SSLEngine on
        SSLCertificateFile /etc/apache2/apache.pem

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

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
    <Location /rutorrent>
        AuthType Digest
        AuthName "gods"
        AuthDigestDomain /var/www/rutorrent/ httpyour.server.ip/rutorrent

        AuthDigestProvider file
        AuthUserFile /etc/apache2/passwords
        Require valid-user
        SetEnv R_ENV "/var/www/rutorrent"
     </Location>
</VirtualHost>

Press CTRL+X and save. Done with those configuration files (there will be two more, but it will be easy)

Chapter 8
Installing ruTorrent

Ok now this is really simple, as long as you do it correctly. So here we go.

Quote
cd /var/www/
wget http://rutorrent.googlecode.com/files/rutorrent-3.1.tar.gz
tar -xvzf rutorrent-3.1.tar.gz
rm rutorrent-3.1.tar.gz
cd /var/www/rutorrent/conf/
nano config.php

Inside the config file, change the line:

Quote
$XMLRPCMountPoint = "/RPC2";

TO:

Quote
$XMLRPCMountPoint = "/rutorrent/RPC2";

Save the file and exit nano.

Chapter 9
Installing Plugins

Ok, you are going to NEED the RPC plugin for ruTorrent to work, as far as other plugins, follow the same method, just with different names

Quote
cd /var/www/rutorrent/plugins
wget http://rutorrent.googlecode.com/files/rpc-3.1.tar.gz
tar xvzf rpc-3.1.tar.gz
rm -f rpc-3.1.tar.gz

That's all there is to it. Some Plug-Ins I suggest:

Quote
http://rutorrent.googlecode.com/files/erasedata-3.1.tar.gz
http://rutorrent.googlecode.com/files/diskspace-3.1.tar.gz
http://rutorrent.googlecode.com/files/darkpal-3.1.tar.gz
http://rutorrent.googlecode.com/files/create-3.1.tar.gz
http://rutorrent.googlecode.com/files/data-3.1.tar.gz
http://rutorrent.googlecode.com/files/unpack-3.1.tar.gz

After you've installed all plugins you want run this command:

Quote
chmod -R 777 /var/www/rutorrent/

Chapter 10
Installing and setting up ProFTPd (FTP Server)

Ok this is like a little mini bonus, it's not required but its good to have to download your torrents. If your just using the seedbox for a buffer then don't worry about it unless you want to download the files from your seedbox.

Quote
apt-get install proftpd

If it prompts you choose "standalone" There you go your done... haha NOT, we have to configure it :P

Quote
/etc/init.d/proftpd stop

Since we will be making changes to the config file, we need to stop the service (before we finish we'll be doing the same for apache :P )

Quote
rm -f /etc/proftpd/proftpd.conf
/etc/proftpd/proftpd.conf

Quote
# This is part of iTpHo3NiX's Complete rTorrent guide from UtN
Include /etc/proftpd/modules.conf
UseIPv6            off
IdentLookups      off
ServerName         "Seedbox FTP Server"
ServerType         standalone
DeferWelcome      off
MultilineRFC2228   on
DefaultServer      on
ShowSymlinks      on
TimeoutNoTransfer   600
TimeoutStalled      600
TimeoutIdle         1200
DisplayLogin      welcome.msg
DisplayChdir      .message true
ListOptions         "-l"
DenyFilter         \*.*/
DefaultRoot         /home/rtorrent/downloads
Port            21
MaxInstances      30
User            proftpd
Group            nogroup
Umask            022   022
AllowOverwrite      on
TransferLog /var/log/proftpd/xferlog
SystemLog /var/log/proftpd/proftpd.log
<IfModule mod_quotatab.c>
QuotaEngine off
</IfModule>
<IfModule mod_ratio.c>
Ratios off
</IfModule>
<IfModule mod_delay.c>
DelayEngine on
</IfModule>
<IfModule mod_ctrls.c>
ControlsEngine      off
ControlsMaxClients   2
ControlsLog         /var/log/proftpd/controls.log
ControlsInverval   5
ControlsSocket      /var/run/proftpd/proftpd.sock
</IfModule>
<IfModule mod_ctrls_admin.c>
AdminControlsEngine   off
</IfModule>
# This is part of iTpHo3NiX's Complete rTorrent guide from UtN

Now we need to add a username and password for you to use for the FTP.

Quote
useradd USER_NAME /home/rtorrent/downloads

Then we need a password

Quote
passwd USER_NAME

And it will prompt you for a password then confirm it.

Ok FTP is all set up run this last command and we're almost done :D

Quote
/etc/init.d/proftpd start

Chapter 11
Starting rTorrent and Getting Everything Running

Run the following commands:

Quote
apache2ctl configtest
/etc/init.d/apache2 force-reload
/etc/init.d/apache2 restart

As long as there are no errors, then we can start rTorrent :D

Quote
cd ~
screen rtorrent

rTorrent should open up, and we then press CTRL+A+D which will detach the window (keep it running in the background) type in "exit" and go to your seedbox!

To get to your seedbox it will be something like this:

http://IP.ADD.RE.SS/rutorrent
Or you could do https
Then enter in your username and password and enjoy!
[09:27] (+lenoch) iTpHo3NiX can even manipulate me to suck dick
[09:27] (+lenoch) oh no that's voluntary
[09:27] (+lenoch) sorry