Howto install rtorrent and wtorrent within an Ubuntu Hardy VE
August 13, 2008
I didn’t look at rtorrent and wtorrent at first. The first software I found for the web based Bittorrent client I searched was TorrentFlux (to be exact Torrentflux-b4rt). The installing was not complicated, but the software is really bad. For once the php part starts for every torrent a new Bittorrent command line program process which takes really really much memory if you’ve like 10 torrents.Their is also the problem that such processes did tend to hang and it was not possible to solve all problems via the web GUI. The next big part was that the web GUI put a really high CPU load on my browsers if the AJAX update was activated (even if it was set to 30 sec). Basically it was an non integrated set of peaces which made more work than it helped me to save, and as I could not set the overall bandwidth I started to search for something else.
It was not easy to find rtorrrent and wtorrent, don’t know why I didn’t find it when I searched for “web based bittorrent client”. I hope my howto helps somewhat in this regard. The combination of these two applications work for me now without any problems. Low CPU load on the client and Server, small footprint on the server and stable. And it works with torrents which didn’t work with torrentflux.
This Howto describes how to setup rtorrent with the web GUI wtorrent (on lighttpd) on an Ubuntu Hardy and in my case within an OpenVZ VE. Of course this Howto works also if you don’t use visualization and it should also work with the current Debian release. Whats special of my setup is that I want to run the rtorrent and wtorrent within a VE, but the finished data should be stored on an remote NFS server (e.g. a small NAS).
1. OpenVZ VE Setup
First we create the VE from a template, you can download one from OpenVZ:
vzctl create XXX --ostemplate ubuntu-8.04-i386-minimal --hostname torrent
After this we add an IP address and activate the NFS client support within the VE:
vzctl set XXX --ipadd XXX.XXX.XXX.XXX --save
vzctl set XXX --features "nfs:on" --save
After this I recommend to change the limits of your VE, I use following (configured via /etc/openvz/conf/XXX.conf)
KMEMSIZE="11055923:11377049"
LOCKEDPAGES="256:256"
PRIVVMPAGES="525000:572715"
SHMPAGES="21504:21504"
NUMPROC="240:240"
PHYSPAGES="0:2147483647"
VMGUARPAGES="33792:2147483647"
OOMGUARPAGES="26112:2147483647"
NUMTCPSOCK="1440:1440"
NUMFLOCK="1880:2060"
NUMPTY="16:16"
NUMSIGINFO="256:256"
TCPSNDBUF="1720320:2703360"
TCPRCVBUF="1720320:2703360"
OTHERSOCKBUF="1126080:2097152"
DGRAMRCVBUF="262144:262144"
NUMOTHERSOCK="360:360"
DCACHESIZE="3409920:3624960"
NUMFILE="9312:9312"
AVNUMPROC="180:180"
NUMIPTENT="128:128"
Check them on you system that the are not too low. Now you start your VE with
vzctl start XXX
vzctl enter XXX
Take a look at configured DNS servers and that you can reach the Internet with this VE. Put your NFS server into /etc/fstab
like this:
yyy.yyy.yyy.yy:/nfsshare /media/nfs nfs soft,udp,auto,user,rsize=32768,wsize=32768 0 0
Don’t forget to create the directory and to apt-get install nfs-common
. After this try to mount the share.
2. Configure your firewall
This part of the setup is based on following assumption:
- Your Linux system is used as DSL/Cable Router and
- you’ve only one wordwide IP address and
- your VE has a private IP address.
It is assumed that your VE can connect to the internet, as only the special setup for the bittorrent ports is shown. The following iptables code will redirect the required ports to your VE, where xxx.xxx.xxx.xxx is the IP of your VE.
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 63963:63981 -j DNAT --to-destination xxx.xxx.xxx.xxx
iptables -A FORWARD -d xxx.xxx.xxx.xxx -p tcp --dport 63963:63981 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -i ppp0 -p tcp --dport 63982 -j DNAT --to-destination xxx.xxx.xxx.xxx
iptables -A FORWARD -d xxx.xxx.xxx.xxx -p tcp --dport 63982 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -i ppp0 -p udp --dport 63982 -j DNAT --to-destination xxx.xxx.xxx.xxx
iptables -A FORWARD -d xxx.xxx.xxx.xxx -p udp --dport 63982 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
3. Install the base and rtorrent
At first the packages we need: (As more packages we can use the less work we’ll have)
apt-get install rtorrent screen mc wget lighttpd gawk php5-cgi php5-common php5-sqlite php5-xmlrpc sqlite unzip php5-curl
Now download following file and save it as /etc/init.d/rtorrent in your VE and activated for automatic startup at boot time with
update-rc.d rtorrent defaults 25
After this we need to add an user under which the rtorrrent process runs and
# adduser --disabled-login rt
# usermod -aG tty rt
# su - rt
$ wget http://robert.penz.name/wp-content/uploads/2008/08/rtorrent.rc -O .rtorrent.rc
$ mkdir /home/rt/session
$ logout
change the /home/rt/.rtorrent.rc
file to your needs. You should try out rtrorrent after any config file change, to avoid problems with syntax errors or that stuff.
# su - rt
$ rtorrent
If it started press CTRL-Q to get out.
$ logout
If all worked start it with /etc/init.d/rtorrent start
4. lighttpd setup
This sections shows how to setup lighttpd for rtorrent XML RPC and for wtorrent. Add "mod_scgi"
to the server.modules
in /etc/lighttpd/lighttpd.conf
and add following there too:
url.access-deny = ("~", ".inc", ".db", ".tpl.php", ".cls.php",)
Create following file /etc/lighttpd/conf-available/10-scgi.conf
with following content:
scgi.server = (
"/RPC2" => # RT_DIR
( "127.0.0.1" =>
(
"host" => "127.0.0.1", # Ip where rtorrent is listening
"port" => 5000, # Port specified in .rtorrent.rc
"check-local" => "disable"
)
)
)
Enable following two configs by setting a symlink:
# cd /etc/lighttpd/conf-enabled/
# ln -s ../conf-available/10-cgi.conf .
# ln -s ../conf-available/10-scgi.conf .
Restart the lighttpd:
/etc/init.d/lighttpd restart
5. Install the wtorrent
Get the newest version and configure it:
# cd /var/www/
# rm index.lighttpd.html
# wget "http://www.wtorrent-project.org/trac/changeset/latest/trunk/?old_path=%2F&format=zip" -O wtorrent.zip
#unzip wtorrent.zip
#mv trunk/wtorrent/* .
#rm -rf trunk
#mkdir tpl_c/
#cd conf
# cp sample.user.conf.php user.conf.php
Change this file according your settings, specially the lines.
define( 'DIR_TORRENTS', 'torrents/');
define( 'DIR_EXEC', '/var/www/');
define( 'DIR_DOWNLOAD', '/home/rt/doing');
After this make everything belong to www-data and read/writable.
#cd /var/www
#chown -R www-data:www-data *
#chmod -R 755 *
Call now
http://xxx.xxx.xxx.xxx/install2.php
After the install is finished do following:
# mv install.php install.php_deactivated
# mv install2.php install2.php_deactivated
You should be able to login via http://xxx.xxx.xxx.xxx/
31 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress
Entries and comments feeds.
Valid XHTML and CSS.
38 queries. 0.073 seconds.
Pretty pretty neat tutorial. Thanks a lot.
I’m having a few issues though – php related, but not only. I guess the problem is basically with wtorrent not being able to connect to rtorrent. I checked again the whole process, dunno what I did wrong.
The main error message:
Error: could not connect to rtorrent.
Other errors:
Warning: disk_total_space() [function.disk-total-space]: No such file or directory in /var/www/cls/rtorrent.cls.php on line 342
and so on, with disk_free_space too (2 times each).
Any suggestion?
Comment by Jun — August 16, 2008 #
I managed to solve the issue myself. I’m still wondering how. Sorry for the previous comment, erase it if it annoys you!
Thanks again for this great howto!
Comment by Jun — August 16, 2008 #
I am having the same issue as you Jun; I have tried reinstalling everything over and over again and I still cannot get it to work. Do you know what you did? Thanks!
Comment by phil — August 24, 2008 #
Please check following:
# netstat -lnp
should return a line like this
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 4176/rtorrent
if you don’t have that rtorrent is not listening on that port.
Comment by robert — August 24, 2008 #
I’m having the exact same issue as Jun. I’ve confirmed that rTorrent is listening on the right port – any other ideas?
Jun – do you have any idea what you did?
Thanks!
Comment by devin — August 31, 2008 #
Take a look there and try if you can connect via the command line commands to rtorrent
http://libtorrent.rakshasa.no/wiki/RTorrentXMLRPCGuide
Comment by robert — August 31, 2008 #
Warning: require_once(wt/cls/ListT.cls.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/lib/inc/utils.inc.php(41) : eval()’d code on line 4
Fatal error: require_once() [function.require]: Failed opening required ‘wt/cls/ListT.cls.php’ (include_path=’/var/www/localhost/htdocs/wtorrent/’) in /var/www/lib/inc/utils.inc.php(41) : eval()’d code on line 4
Please help…
Comment by cinowell — September 15, 2008 #
hmmm … why does it search in
/var/www/lib/inc/utils.inc.php and not in /var/www/localhost/htdocs/wtorrent/lib/inc/utils.inc.php
I think there is some path wrong.
Comment by robert — September 15, 2008 #
otherwise I’ve no idea. maybe your version does not work. did you try an older? or talked to the wtorrent author?
Comment by robert — September 15, 2008 #
Getting the same error here:
Warning: require_once(wt/cls/ListT.cls.php) [function.require-once]: failed to open stream: No such file or directory in /var/www/wt/lib/inc/utils.inc.php(41) : eval()’d code on line 4
Fatal error: require_once() [function.require]: Failed opening required ‘wt/cls/ListT.cls.php’ (include_path=’/var/www/localhost/htdocs/wtorrent/’) in /var/www/wt/lib/inc/utils.inc.php(41) : eval()’d code on line 4
Comment by Corey — September 16, 2008 #
I resolved the above error but editing the path in to index.php in usr.conf.php since mine wasn’t set up like the default.
Now I can get into wTorrent, however it says “Error: could not connect to rtorrent” at the top. đ
Comment by Corey — September 16, 2008 #
1. does this command return the same
# netstat -npl | grep rtorrent
….
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 622/rtorrent
…..
2. what happens if you type that into your browser
http://yourserver/RPC2/
an empty page should be shown without delay. if not the lighttpd can’t talk to the rtorrent.
3. try to access the rtorrent with an xmlrpc client as shown here:
http://libtorrent.rakshasa.no/wiki/RTorrentXMLRPCGuide
Comment by robert — September 16, 2008 #
i can never enter the correct username and passowrd. i’ve even tried manually changing the
define( ‘RT_USER’, ‘john’);
define( ‘RT_PASSWD’, ‘smith’);
but to no avail.
Comment by Ben — September 24, 2008 #
define( âRT_USERâ, âjohnâ);
define( âRT_PASSWDâ, âsmithâ);
but to no avail.
—
same here.
Comment by thorin — September 24, 2008 #
the RT_USER and RT_PASSWD is not the password you use to login to wtorrent. its the password the wtorrent uses to talk to rtorrent, and you need only to set it if you configured lighttpd that way. in my howto I did not do that
for the wtorrent password you need to call install.php or install2.php depending on your version of wtorrent. there you can set the password.
Comment by robert — September 26, 2008 #
Good job!It’s work on my ubuntu 8.04.
You explain better than official website :-).
I will try this howto on a NSLU2 after.
Je suis Français, pardon pour les fautes ;-).
Comment by pierre — October 20, 2008 #
[…] public links >> sqlite Howto install rtorrent and wtorrent within an Ubuntu Hardy VE Saved by noellana on Thu 23-10-2008 Always index your tables. Always Saved by energia on Thu […]
Pingback by Recent Links Tagged With "sqlite" - JabberTags — October 25, 2008 #
Hi.
Nice guide, i have not come this far with any of the others i found =)
But i got the âError: could not connect to rtorrentâ message. =/
“# netstat -npl | grep rtorrent” shows:
tcp 0 0 127.0.0.1:5000 0.0.0.0:* LISTEN 30026/rtorrent
“http://127.0.0.1/RPC2/”
shows the empty page.
So now i have tried some of the commands shown in the link that was posted, but i don’t know what i’m getting out of them…
ex:
“andreas@PC:~$ xmlrpc localhost set_upload_rate 1000k
Result:
Integer: 0”
“andreas@HTPC:~$ xmlrpc localhost download_list
Error: RPC failed at server. Wrong object type. (-503)
what does that mean? what can i do to fix this? =/
/Andreas
Comment by Andreas — November 22, 2008 #
“Error: RPC failed at server. Wrong object type. (-503)
it seems download_list is now requiring an argument such as “main”, “stopped”, etc. previously it was supposed to default to “main” if no argument was supplied”
ok so that was a user error, but tested a new one:
“andreas@PC:/etc/rtorrent$ xmlrpc localhost download_list started
Result:
Array of 0 items:”
/Andreas
Comment by Andreas — November 22, 2008 #
lighttpd error.log
“2008-11-22 17:00:08: (mod_fastcgi.c.2610) FastCGI-stderr: XML-RPC: xmlrpcmsg::parseResponse: no response received from server.”
Comment by Andreas — November 22, 2008 #
[…] major pain in the ass. So if you plan to install wtorrent, the following pages will help you a lot: http://robert.penz.name/82/howto-install-rtorrent-and-wtorrent-within-an-ubuntu-hardy-ve/ – the included init script seems to have kind of a bug though, failed to detect the session path […]
Pingback by Moved from Torrentflux-b4rt to wtorrent | schichtleiter.1338.at — January 7, 2009 #
I think I followed the instructions correctly, but I ended up with no install2.php file. I tried running the install.php instead, but got a message saing the site isn’t available.
Any idea what I missed?
Comment by rj — January 20, 2009 #
Okay, well, I just went to the wtorrent source site and downloaded the install2.php. I ran it, but it screwed up my download directory setting; so I edited the user.conf.php and put the correct value in there.
I haven’t actually put any torrents in there yet, but it looks good so far…
Comment by rj — January 20, 2009 #
Hey it works great for the most part! The startup script seems to bug out on occasion though. Got any idea what it would do that?
It says : cannot find readable session directory ./.rtsession from config /home/rt/.rtorrent.rc. check permissions
However, the file is clearly there because it works fine sometimes.
Comment by Eric Z. — February 14, 2009 #
For people encountering the disk space issue, verify that the directory pointed to by DIR_DOWNLOAD in the wTorrent user.conf.php file actually exists.
If you were simply using all the directories specified in this guide, you would have to ‘mkdir /home/rt/doing’ as the rt user.
Comment by robotech — March 2, 2009 #
im having this error after configure lighttpd
root@ks304603:~# /etc/init.d/lighttpd restart
* Stopping web server lighttpd [ OK ]
* Starting web server lighttpd Duplicate config variable in conditional 0 global: scgi.server
2009-09-13 23:13:38: (configfile.c.855) source: /etc/lighttpd/lighttpd.conf line: 254 pos: 15 parser failed somehow near here: (EOL)
[fail]
anyone could help me i had it running but somehow the .rtsession got locked
and rtorrent wouldn’t run and .rtorrent.rc got blank i had to configure it all over again now its all ok again just lighttpd missing i cant iniciate it to configure the Wtorrent install.php
Comment by Tiago Fazendeiro — September 13, 2009 #
Without your lighttpd.conf file it is hard to help you. Maybe you forgot to close a { or (.
Comment by robert — September 14, 2009 #
@Tiago Fazendeiro
I had that same error, and solved it by removing /etc/lighttpd/conf-available/10-cgi.conf & /etc/lighttpd/conf-available/10-scgi.conf, as both are already in the main lighttpd.conf file
Also, I’m getting the cannot connect to rTorrent message, I’ve verified that rtorrent is listening, and when attempting to test the xmlrpc commands (eg xmlrpc localhost download_list), I get the following error (Error: HTTP request completed with HTTp error -404. Fatal Error: 404 Not Found (Not Found) (-504)) I’m using lighttpd listening on port 81
Comment by Conor Duffy — December 6, 2009 #
[…] of the information posted on these guides: http://www.wtorrent-project.org/trac/wiki/DebianInstall/ http://robert.penz.name/82/howto-install-rtorrent-and-wtorrent-within-an-ubuntu-hardy-ve/ […]
Pingback by Script for rTorrent + wTorrent on Ubuntu | iHiDE.iN — January 11, 2010 #
Make sure that the fastcgi, and cgi conf files are moved from conf-available to conf-enabled. This had me stuck for a bit with 403 errors. Probably mostly due to my inexperience with the application.
Comment by EricB — April 3, 2010 #
EricB is correct.
# cd /etc/lighttpd/conf-enabled/
# ln -s ../conf-available/10-cgi.conf .
# ln -s ../conf-available/10-scgi.conf .
# ln -s ../conf-available/10-fastcgi.conf .
was necessary for lighttpd to not sprout a 403.
Comment by ginub — December 31, 2010 #