Powered By

Powered by Blogger

Minggu, 13 Desember 2009

Compile And Set Up rTorrent and wTorrent In Debian 5 Lenny [Complete How-to]

wtorrent rtorrent

The reason I am writing this post is because I tried many howto's which didn't work and I eventually ended up combining some to get both rtorrent and wtorrent to install and run on my Debian 5 Lenny VPS (thanks to Costin for the VPS).

In case you don't know: wtorrent is a WebUI for rtorrent, a command line Bittorrent client.

Be aware, there are quite a few steps on doing this, so you need a lot of patience and time. Let's get started!

1. Install needed packages (for most of this tutorial) from the repositories:

apt-get install apache2.2-common apache2-utils apg 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 libapr1 libaprutil1 libc6-dev libcurl3 libcurl3-openssl-dev libexpat1 libidn11 libidn11-dev libkadm55 libkrb5-dev libmagic1 libncurses5-dev libneon26 libpcre3 libpq5 libsigc++-2.0-dev libsqlite0 libsqlite3-0 libssl-dev libssp0-dev libstdc++6-4.1-dev libsvn1 libtool libxml2 lighttpd linux-kernel-headers lynx m4 make mime-support ntp ntpdate openssl patch perl perl-modules php5 php5-cgi php5-common php5-sqlite unzip pkg-config screen sqlite subversion ucf zlib1g-dev

If you get an "lighttpd" error, it means there is something already running on port 80. So edit the lighttpd config file:
nano /etc/lighttpd/lighttpd.conf

Scroll down to the port and uncomment the line "server.port = 81" and save the file.
Now run:
apt-get install -f

If that doesn't do it, you may also use:
/etc/init.d/lighttpd force-reload

And run this again:
apt-get install -f

All the packages should be now installed and configured.

Also, make sure you don't have rtorrent or libtorrent installed:
apt-get remove rtorrent libtorrent*

2. Download and compile xmlrpc-c
svn co https://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc-c
cd xmlrpc-c
./configure --disable-cplusplus
make install

3. Download and compile libtorrent and rtorrent

Revision 1105 is needed because the last one fails to compile.
mkdir rtorrent-svn
cd rtorrent-svn
svn co svn://rakshasa.no/libtorrent/trunk --revision 1105
cd trunk
cd libtorrent
make install
cd ../rtorrent
./configure --with-xmlrpc-c
**after that command make sure you see "checking for XMLRPC.... OK" near the end of the outputted text**
make install

4. Downloading and setting up wtorrent

wget "http://www.wtorrent-project.org/trac/changeset/latest/trunk/?old_path=%2F&format=zip" \

-Extract it:
unzip -d /tmp/ /tmp/wtorrent.zip

-Move the wtorrent source:
mv /tmp/trunk/wtorrent /opt/wtorrent

-Setting the file permissions:
find /opt/wtorrent -type f | xargs /bin/chmod 644

-Create folders needed by wtorrent and setting their permissions:

mkdir --parent /var/lib/wtorrent/data
mkdir --parent /var/lib/wtorrent/db
mkdir --parent /var/lib/wtorrent/tpl_c
mv /opt/wtorrent/torrents /var/lib/wtorrent/torrents
chown -R www-data:www-data /var/lib/wtorrent
chown -R rtorrent:www-data /var/lib/wtorrent/data

-Create symbolic links
ln -s /var/lib/wtorrent/tpl_c /opt/wtorrent/tpl_c
ln -s /var/lib/wtorrent/torrents /opt/wtorrent/torrents

-Making sure wtorrent can add configuration files:
chown www-data:www-data /opt/wtorrent/conf/

-Configuring wtorrent:
sed -i -e "/\$defaults/,/\$user_options/s|^\(.*db_file.*=>\).*$|\1 '../../var/lib/wtorrent/db/database.db',|" \
-e "/\$defaults/,/\$user_options/s|^\(.*dir_torrents.*=>\).*$|\1 'torrents/',|" \
-e "/\$defaults/,/\$user_options/s|^\(.*dir_exec.*=>\).*$|\1 '/opt/wtorrent/',|" \
-e "/\$defaults/,/\$user_options/s|^\(.*dir_download.*=>\).*$|\1 '/var/lib/wtorrent/data/',|" \

5. Setting up rtorrent

-Make sure we can run rtorrent as a daemon:
apt-get install screen

-Create a user dedicated to running rTorrent in the background:
adduser --system --shell /bin/sh --home /var/lib/rtorrent rtorrent

-Create the files that will be used by rtorrent:

mkdir --parent /var/lib/rtorrent/sessions
mkdir --parent /var/lib/rtorrent/torrents/doing
mkdir --parent /var/lib/rtorrent/torrents/watch
mkdir --parent /var/lib/rtorrent/torrents/done
chown -R rtorrent:nogroup /var/lib/rtorrent

-Getting the rtorrent config file:
wget http://howto.landure.fr/gnu-linux/debian-4-0-etch/installer-wtorrent-sur-debian-5-0-lenny/rtorrent.rc \

-And create a symbolic link:
ln -s /etc/rtorrent.rc /var/lib/rtorrent/.rtorrent.rc

-In the same way, we set up the init.d script:
wget http://howto.landure.fr/gnu-linux/debian-4-0-etch/installer-wtorrent-sur-debian-5-0-lenny/rtorrent \
chmod +x /etc/init.d/rtorrent

-Start the rtorrent daemon:
/etc/init.d/rtorrent start

-Make the daemon start automatically:
update-rc.d rtorrent defaults

Note: if rtorrent doesn't start after a crash, delete the lock file:
rm /var/lib/rtorrent/sessions/rtorrent.lock

6. Setting up the SCGI server

-Create a random username and password for the SCGI server:
SCGI_LOGIN=$(/usr/bin/apg -q -a  0 -n 1 -M NCL)
SCGI_PASSWORD=$(/usr/bin/apg -q -a 0 -n 1 -M NCL)

-Use htpasswd to store them in a file used by lighttpd:
htpasswd -cb /etc/lighttpd/rtorrent.pwd ${SCGI_LOGIN} ${SCGI_PASSWORD}

-Configure wTorrent to use these authentication settings:
sed -i -e "/\$defaults/,/\$user_options/s|^\(.*rt_user.*=>\).*$|\1 '${SCGI_LOGIN}',|" \
-e "/\$defaults/,/\$user_options/s|^\(.*rt_passwd.*=>\).*$|\1 '${SCGI_PASSWORD}',|" \
-e "/\$defaults/,/\$user_options/s|^\(.*rt_auth.*=>\).*$|\1 true,|" \

-Configure Lighttpd to "serve" the SCGI server to rtorrent. Paste all of the following lines at once in the terminal:

echo '# rTorrent SCGI configuration.

server.modules += ( "mod_scgi", "mod_auth" )

scgi.server = (
"/RPC2" => # RT_DIR
( "" =>
"host" => "", # Ip where rtorrent is listening
"port" => 5000, # Port specified in .rtorrent.rc
"check-local" => "disable"

auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/lighttpd/rtorrent.pwd"
auth.require = (
"/RPC2" =>
"method" => "basic",
"realm" => "XML-RPC",
"require" => "valid-user"
' | /usr/bin/tee /etc/lighttpd/conf-available/10-rtorrent.conf

-Activate the recent configuration:
/usr/sbin/lighty-enable-mod rtorrent

-Reload lighttpd:
/etc/init.d/lighttpd force-reload

7. Configure wtorrent

-Create a user configuration file by default, and we make writable by wtorrent:
cp /opt/wtorrent/conf/sample.user.conf.php /opt/wtorrent/conf/user.conf.php
chown www-data:www-data /opt/wtorrent/conf/user.conf.php

-Make wtorrent accessible on the internet by creating a symbolic link in /var/www:
ln -s /opt/wtorrent /var/www/wtorrent

8. The almost final wtorrent configuration via web interface

Open a browser with: http://localhost/wtorrent/install.php (or, if you are doing this remotely like me, enter the IP instead of 'localhost').

Now click on "Try configuration" and if everything is fine, click on "Save configuration".

a) If you modified the lighttpd port to 81 (see step 1), enter port 81 here instead of 80
b) If you get a database error such as: "Error: cannot create database file, please check permissions.", modify the "Database file" input box to "db/database.db" like this:

wtorrent install

and run these commands:
chown -R www-data:www-data /var/www/wtorrent
chmod 777 /var/www/wtorrent

Alternatively, you can try to only chown the /db/ folder:
chown www-data:www-data /var/www/wtorrent/db

If you still get this error, try removing the database.db file:
rm /var/lib/wtorrent/db/database.db 

, reload the /install.php web page and click on "Try configuration". wtorrent will create a new configuration file.

9. Removing install.php and reverting file permission for the conf file

If everything works ok now, remove the install.php file and protect the conf file:
rm /opt/wtorrent/install.php
chown root:root /opt/wtorrent/conf/user.conf.php

Now launch wtorrent by going to http://localhost/wtorrent (or the IP of the machine running wtorrent instead of localhost).

Further reference / credits:

wtorrent Debian / Ubuntu installation guide
rtorrent with wtorrent on debian etch complete HOWTO
Installer wTorrent sur Debian 5.0 Lenny - the most substantial part of this post. Thanks!
How To Compile rTorrent From SVN In Ubuntu 9.10 Karmic Koala / Debian 5 Lenny With Magnet Link Support

Hopefully I have not forgotten any steps. If something does no work, try consulting the 4 links above.

Tidak ada komentar:

Posting Komentar