📜 ⬆️ ⬇️

Installing and configuring the rtorrent + wtorrent link in Debian

Habrahabr has repeatedly raised the problem of creating a home server. Accordingly, using the search, you can easily find some good articles on this topic. There you will, in particular, find out why this is all you need.
But, unfortunately, none of the articles on the Internet fully disclose the problem of installing the rtorrent + wtorrent bundle on the Debian system (or Ubuntu, which is practically the same). The main difficulty lies in several obvious and not very "pitfalls":

- Debian contains some packages with outdated versions of libraries that are incompatible with the latest version of rtorrent / libtorrent;
- existing manuals and howto only contain information on how to install this bundle on the lighttpd server, which is not always convenient (for example, I have a couple of sites on my home server that are better run under Apache);
- no manual takes into account all the details of the installation.

Given these circumstances, this copy-paste guide was written, which I hope will help you in the difficult task of taming rtorrent / wtorrent.
')
We put "pure" Debian 4.0. Next in the console under the root set the necessary packages:

apt-get install apache-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 libapache-mod-php5 \
libapr1 libaprutil1 libc6-dev libcurl3 libcurl3-openssl-dev libexpat1 \
libidn11 libidn11-dev libkadm55 libkrb5-dev libmagic1 libncurses5-dev \
libneon26 libpcre3 libpq4 libsigc++-2.0-dev libsqlite0 libsqlite3-0 \
libssl-dev libssp0 libstdc++6-4.1-dev libsvn1 libtool libxml2 linux-kernel-headers \
lynx m4 make mime-support ntp ntpdate openssl patch libapache2-mod-scgi\
perl perl-modules php5 php5-cgi php5-common php5-sqlite pkg-config screen


Let's do Apache over:

a2enmod suexec
a2enmod scgi


We will set the rest from sors. First, install xmlrpc:

cd
svn co xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c
cd xmlrpc-c
./configure --disable-cplusplus
make
make install

Next c-ares:

cd
wget c-ares.haxx.se/c-ares-1.6.0.tar.gz
tar xzf c-ares-1.6.0.tar.gz
cd c-ares-1.6.0
./configure
make
make install


Next libcurl:

cd
wget curl.haxx.se/download/curl-7.19.3.tar.gz
tar xzf curl-7.19.3.tar.gz
cd curl-7.19.3
./configure --enable-ares
make
make install


Now you can build libtorrent and rtorrent:

cd
mkdir rtorrent
cd rtorrent
svn co svn://rakshasa.no/libtorrent/trunk
svn up
cd trunk
cd libtorrent
./autogen.sh
./configure
make
make install
cd ../rtorrent
./autogen.sh
./configure --with-xmlrpc-c
make
make install


Add the user rt and create all sorts of service folders:

useradd rt
cd /home/rt
mkdir ./torrents
mkdir ./torrents/watch
mkdir ./torrents/doing
mkdir ./torrents/done
mkdir ./.rtsession
chown rt:rt /home/rt -R
chmod 777 /home/rt/torrents -R


Create a startup script for rtorrent and add it to autoload:

cd
wget re-hash.ru/pub/rtorrent.tgz
tar xzf rtorrent.tgz
cp rtorrent /etc/init.d
chmod a+x /etc/init.d/rtorrent
update-rc.d rtorrent defaults 25


Create a configuration file for rtorrent:

nano /home/rt/.rtorrent.rc

Let's write there the following:

scgi_port = localhost:5000
min_peers = 40
max_peers = 1000
min_peers_seed = 10
max_peers_seed = 50
max_uploads = 15
directory = /home/rt/torrents/doing
session = /home/rt/.rtsession
schedule = watch_directory,5,5,load_start=/home/rt/torrents/watch/*.torrent
schedule = tied_directory,5,5,start_tied=
schedule = untied_directory,5,5,close_untied=
on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/home/rt/torrents/done/ ;d.set_directory=/home/rt/torrents/done/"
on_start = link1,"create_link=tied,,.started"
on_stop = link1,"delete_link=tied,,.started"
on_finished = link1,"create_link=tied,,.finished"
on_erase = link1,"delete_link=tied,,.finished"
schedule = low_diskspace,5,60,close_low_diskspace=100M
port_range = 63963-63963
port_random = no
check_hash = yes
use_udp_trackers = yes
encryption = allow_incoming,try_outgoing,enable_retry
dht = auto
dht_port = 63982


If you have a router, it is necessary to open ports 63963 and 63982 for the server with rtorrent.
Next, edit the /etc/apache2/apache.conf file, add the following lines somewhere:

SCGIMount /RPC2 127.0.0.1:5000

<VirtualHost *:80>
SuexecUserGroup rt rt
ServerName torrent
#ServerAlias www.torrent
DocumentRoot /var/www/torrent/www
CustomLog /var/www/torrent/access.log combined
ErrorLog /var/www/torrent/error.log
<Directory "/var/www/torrent/www">
Options FollowSymLinks Includes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
#ScriptAlias /cgi-bin/ "/var/www/torrent/cgi-bin/"
</VirtualHost>


Now install wtorrent. To do this, do the following:

mkdir /var/www/torrent/www
cd /var/www/torrent/www
svn co svn://canbruixa.homelinux.net/repos/trunk/wtorrent/
mv * ..
cd ..
rmdir wtorrent
mkdir data
nano ./conf/home.conf.php


In the file ./conf/home.conf.php we write the following:

<?php
define( 'URL', 'http://torrent/' );
define( 'BASE', 'http://torrent/' );
define( 'DB_FILE', 'db/database.db');
define( 'RT_HOST', 'localhost');
define( 'RT_PORT', 80);
define( 'RT_DIR', 'RPC2/');
define( 'RT_AUTH', false);
define( 'RT_USER', '');
define( 'RT_PASSWD', '');
define( 'NO_MULTICALL', true);
define( 'DIR_TORRENTS', 'torrents/');
define( 'DIR_EXEC', '/var/www/torrent/www');
define( 'PERM_TORRENTS', 0777);
define( 'DIR_DOWNLOAD', '/home/rt/doing');
define( 'DIR_LANG', 'home/lang/' );
define( 'DIR_TPL', 'home/tpl/' );
define( 'DIR_TPL_COMPILE', 'tpl_c/' );
define( 'DIR_TPL_HTML', 'home/html/' );
define( 'DIR_BACKUP', 'backup/' );
define( 'DIR_UPLOAD', 'torrents/');
define( 'TITLE', 'wTorrent' );
define( 'META_TITLE', 'rTorrent web interface' );
define( 'META_KEYWORDS', 'rtorrent xmlrpc interface php web html' );
define( 'META_DESCRIPTION', 'rtorrent web inrface using xmlrpc' );
define( 'DIR_CSS_DETALLS', 'home/css/detalls.css' );
define( 'DIR_CSS_ESTIL', 'home/css/estil.css' );
define( 'DIR_JS', 'home/js/javasc.js' );
define( 'DIR_JSHADE', 'home/js/shadedborder.js' );
define( 'DIR_JSPROTO', 'home/js/prototype.js' );
define( 'DIR_SCRIPTACULOUS','home/js/scriptaculous/scriptaculous.js');
define( 'DIR_FAVICO', 'favicon.ico' );
define( 'DIR_IMG', 'home/img/' );
define( 'SRC_INDEX', 'index.php' );
define( 'SCRAMBLE', false);
define( 'APP', 'wTorrent' );
require_once( 'lib/inc/includes.inc.php' );
autoload( 'lib/cls/', 'cls/', 'home/cls/' );
ini_set( 'include_path', DIR_EXEC );
?>


Next, we write permissions for all necessary folders and files:

chown -R rt:rt /var/www/torrent/www
chown -R www-data:www-data db torrents tpl_c
chmod data 755
touch ./db/database.db


In order for everything to work, it is best to restart the server. If you want to access the web-interface from the local machine, simply add the line

127.0.0.1 torrent

in the / etc / hosts file. If you want to access the interface from another machine, add the above line to the hosts on it, replacing 127.0.0.1 with the IP of the machine with rtorrent.

After the reboot, open the URL torrent / install.php in the browser and perform the installation. You can leave everything by default, except for the username and password, of course. After installation, do not forget to kill the file /var/www/torrent/www/install.php.

If I forgot something, I will answer in the comments. I would be grateful for the constructive comments on this manual.

Source: https://habr.com/ru/post/51214/


All Articles