WDTV Optware tips #5: wtorrent – webgui for rtorrent


Yes, I’ve finally gotten around to part 3 of 3 in my rtorrent with wtorrent tutorial. Wtorrent is an excellent webui for rtorrent and after this tutorial you’ll be able to manage rtorrent from the web…forward a port and you can even connect to your wdtv from the internet to queue up torrents!

In order to take advantage of this tutorial you must either be running WDLXTV or Zoranders ext3-boot. You must also have my Optware for WDTV package installed, that stuff is covered elsewhere. I’ll be including every necessary step here, so you might be able to skip around if you already have some of this done.

This writeup presumes that you have already executed the steps from part 1 and part 2. If you haven’t done them yet, then get over and complete them first!

First ssh/telnet into your WDTV, then update your Optware feed and download the latest wtorrent.

$ ssh root@wdtv-01

BusyBox v1.10.0 (2009-02-15 05:09:42 CST) built-in shell (msh)
Enter 'help' for a list of built-in commands.

# ipkg update
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//Packages.gz
Inflating http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//Packages.gz
Updated list of available packages in /opt/lib/ipkg/lists/wdtv
Successfully terminated.
# cd /tmp
# wget 'http://www.wtorrent-project.org/trac/changeset/latest/trunk/?old_path=%2F&format=zip' -O wtorrent-current.zip
--2009-04-08 07:11:41-- http://www.wtorrent-project.org/trac/changeset/latest/trunk/?old_path=%2F&format=zip
Resolving www.wtorrent-project.org...
Connecting to www.wtorrent-project.org||:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 453058 (442K) [application/zip]
Saving to: `wtorrent-current.zip'

100%[======================================>] 453,058 771K/s in 0.6s

2009-04-08 07:11:43 (371 KB/s) - `wtorrent-current.zip' saved [453058/453058]

Now that we have the latest version, lets unzip it to our web server location and do a bit of file maintenance to get things in working order.

# unzip wtorrent-current.zip -d /opt/share/www/
inflating: trunk/wtorrent/torrents/.htaccess
inflating: trunk/wtorrent/cls/torrent.cls.php
inflating: trunk/wtorrent/cls/rtorrent.cls.php
inflating: trunk/wtorrent/wt/js/ajax.js
inflating: trunk/wtorrent/install.php
inflating: trunk/wtorrent/index.php
# cd /opt/share/www
# mv trunk/wtorrent/ .
# ls
index.php trunk wtorrent
# rmdir trunk/
# ls
index.php wtorrent
# mkdir wtorrent/tpl_c
# touch wtorrent/db/database.db
# cp wtorrent/conf/sample.user.conf.php wtorrent/conf/user.conf.php
# chmod -R 777 wtorrent

Whew, now that bit of (undocumented) house cleaning is taken care of we need to modify the configuration for rtorrent to enable the xmlrpc server.

# echo '# xmlrpc support for wtorrent
scgi_port =' >> /opt/etc/rtorrent.conf

You’ll have to restart rtorrent after the line above. If you’re successfull your rtorrent should have a message like so:

# /opt/etc/init.d/S99rtorrent restart


I still haven't gotten around to patching S99rtorrent in Optware. For a temporary solution there is an S99rtorrent that will work for now, check the comment section of part 1of3 of this series.

*** rTorrent 0.8.2/0.12.4 - wdtv-01:1282 ***
[View: main]

( 7:25:43) Using 'select' based polling.
( 7:25:43) Ignoring ~/.rtorrent.rc.
( 7:25:43) XMLRPC initialized with 444 functions.
( 7:25:43) The SCGI socket is bound to a specific network device yet may still p

[Throttle 40/300 KB] [Rate 0.0/ 0.0 KB] [Port: 51780] [U 0/18] [D 0/70] [H

Note: I’ve done the minimal patching required to get rtorrents init.d script syntax error free, will patch Optware tomorrow if I have time ;)

Ok, we’re gettin closer. Now we just need to install one package I accidentally left off (sqlite2) the lighttpd tutorial and then enable the modules in php.ini.

# ipkg install sqlite2
Installing sqlite2 (2.8.17-2) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//sqlite2_2.8.17-2_mipsel.ipk
Configuring sqlite2
Successfully terminated.

# echo 'extension=pdo.so
extension=pdo_sqlite.so' >> /opt/etc/php.ini

Now its time to enable and configure the SCGI server module in lighttpd. For good style I’ll place the config file in /opt/etc/lighttpd/conf.d/. All .conf files located in this directory are parsed each time lighttpd starts. This makes things a bit more modular.

To edit:

# nano /opt/etc/lighttpd/conf.d/11-mod_scgi.conf

inside 11-mod_scgi.conf add:

server.modules += ( "mod_scgi" )

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

The next step is optional. If your wdtv is not accessible from the public internet, then you can skip this step. If you are forwarding an external port to your wdtv so you can manage wtorrent remotely, then yes you definitely want to do this.

To edit:

# nano /opt/etc/lighttpd/conf.d/12-mod_auth.conf

inside 12-mod_auth.conf add:

server.modules += ( "mod_auth" )

auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/opt/etc/lighttpd/.passwd"

auth.require = ( "/wtorrent" =>
"method" => "basic",
"realm" => "wtorrent.on.wdtv",
"require" => "valid-user"

Now when you attempt to access wtorrent you’ll be prompted for a username/password, without disclosing whats behind the auth. One last thing we need to do before SCGI is finished, we need to create the directory and set its permissions.

# mkdir /opt/share/www/RPC2
# chmod 777 /opt/share/www/RPC2

We have authorization set up, but one problem…What users are authorized to connect? Inside of 12-mod_auth.conf you should notice these two lines:

auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/opt/etc/lighttpd/.passwd"

Valid user/password combinations are stored in /opt/etc/lighttpd/.passwd. We’ll need to create a little script to add user/password combo’s to this file.

to edit:

# nano /opt/bin/htpasswd && chmod a+x /opt/bin/htpasswd

inside /opt/bin/htpasswd add:



hash=`echo -n "$user:$realm:$pass" | md5sum | cut -b -32`
echo "$user:$realm:$hash"

Now I’ll generate a user so I can connect, when things are finished.

# htpasswd b-rad.cc wtorrent.on.wdtv testing >> \

You can change wtorrent.on.wdtv to anything you desire (maybe something less obvious), just be sure there are no spaces in the string.

Are we there yet? Almost. We first need to restart lighttpd to reflect our config changes and kill php-fcgi so it loads the sqlite modules.

# killall php-fcgi
# /opt/etc/init.d/S80lighttpd restart
Stopping web server: lighttpd
Starting web server: lighttpd

Now we're finally ready to run wtorrents web installer and get things underway.

Open your favourite web browser and enter:

http://<your wdtv's ip>:8081/wtorrent/install.php

You should be welcomed by the install screen. Heres what my config looks like...notice that it asks you for rtorrents scgi port, but I've entered the webserver port instead. I imagine that is a typo on wtorrents part, you must enter your lighttpd port there. When SCGI was enabled earlier we set it to only be exposed to the loopback, so no need to have a username/password there.

wtorrent install.php

Note: don't copy my config information verbatim unless your directories are exactly like mine

Once you've filled the information out correctly, click on try configuration. You should see this:


If you don't then you haven't been following very well ;)

If it says you're good, then click save configuration. It should report success like so:

wtorrent config saved


Now there are two things that we need to do before starting, delete install.php like wtorrents asks and protect the wtorrent db from being downloaded.

# rm /opt/share/www/wtorrent/install.php

That takes care of the install script, in order to protect the database we have to modify /opt/etc/lighttpd/lighttpd.conf

# nano /opt/etc/lighttpd/lighttpd.conf

You need to find this line:

url.access-deny = ( "~", ".inc" )

and replace it with this line:

url.access-deny = ("~", ".inc", ".db", ".tpl.php", ".cls.php",)

Restart lighttpd now to reflect that change, then how bout we take wtorrent for a testdrive?

# /opt/etc/init.d/S80lighttpd restart

Ok, navigate to http://<your wdtv's ip>:8081/wtorrent. You're greeted by wtorrents internal log in page, if you enabled mod_auth earlier you'll have to enter a user/password before you access wtorrent.

wtorrent log in

After logging in you're dropped in to the torrent listings. If your rtorrent has torrents currently running you'll see them here, I don't have anything downloading at the moment.

wtorrent empty view

I'll click on add torrent to see about adding something.

wtorrent upload page

I've selected something and checked private, since this is a private torrent, now I'll click to upload.

wtorrent torrent uploaded

Lets go back to the main view to see if the torrent is running.

wtorrent view torrent

Awesome! You now have the ability to add torrents to your wdtv from anywhere in the world...and you don't have to go to the console at all!!! :D

Some things to note:

  • the wdtv is not a powerful web server, give rtorrent/wtorrent time to respond and don't be impatient.

  • extracting archives can be painful

I spend a tremendous amount of time hacking the WDTV firmware and writing up stuff like this, so if you appreciate my efforts please donate a little something using the link below : ) Thanks & enjoy.

April 9th, 2009 00:59

Have you compared rtorrent+wtorrent with transmission, which provides its own web UI, and for which different Windows/Linux clients are available (transmission remote gui & transmission remote dotnet) ?

<<< edit: rtorrent is transparent when i run it, i don’t like transmission because i can tell its there when its running. Thats on a capable machine too, i’ve used rtorrent on nslu2′s for years so I trust its performance on all sizes. I haven’t had a windows computer in a very long time so I’m sorta clueless about anything in that arena. –b-rad >>>

April 9th, 2009 20:33

Very good write up. The only thing I saw missing was configuring of user.conf.php. There are a couple of lines in there that need edited, or else you will get a blank (white)page when trying to load wtorrent. Not a major mistake, but you mention restarting a couple of the init scripts, but give the wrong file name(/opt/etc/init.d/S99rtorrent, instead of /opt/etc/init.d/rtorrent.) Something most will figure out on there own and fix and keep on trucking with the guide.

<<< edit: it is /opt/etc/init.d/S99rtorrent and I didn’t touch anything (pretty sure) in user.conf.php either. If anyone tries this fresh and finds there is an error, please mention it. –b-rad >>>

April 9th, 2009 22:17

I did start fresh. I believe the blank page error will occur if you do not edit this section in user.conf.php. If you look at your lighttpd log, you will see some error about not being able to find some file. This may be useful if anyone else encounters the error.

Change the below section too…
// Full path to application directory (where index.php is)
define( ‘DIR_EXEC’, ‘/var/www/localhost/htdocs/wtorrent/’);

to this

// Full path to application directory (where index.php is)
define( ‘DIR_EXEC’, ‘/tmp/mnt/opt/share/www/wtorrent/’);

<<< edit: Strange. i totally didn’t do that, but I’ll run through it again tommorrow and see if I somehow forgot I did. –b-rad >>>

John Grover
April 10th, 2009 00:34

b-rad i have a request!!!
I use my WDLXTV as part of my home cinema kit with about 400 movies which include about 100 in HiDef. My wife loves looking through the DVD covers but would like information about the movie from the likes of imbd move database to help her choose a movie.

All my movies are in individual folders as i use http://www.mymovies.dk software to tag them with cover art and movie info for use with windows media centre. i.e.Genre, Rating, Movie Summary ect.

So would it be possible to include in a future update as im sure this add even more value to this great product.

<<< edit: almost anything is possible, but the type of thing you describe would require sponsoring me to do it. I have more than enough on my plate. –b-rad >>>

April 10th, 2009 03:42


The first thing I want to say is: “Great work”

I would like to ask you to publish all your files on bittorent network. I am ready to keep your files in my bittorent share.
Are there any lizenensing issues, not allowing me to do so?

Best regards!


<<< edit: I’d prefer my files not be hosted on bittorrent. I’d like people to come here, so that they get the correct/latest versions and provide feedback directly so that I know about bugs. Thanks. –b-rad >>>

April 10th, 2009 09:54

Thanks, had a few minor bumps, but likely because being rough around linux…
Guide was very helpful.

<<< edit: lemme know if there are any errors, i finally saw the two init.d errros takenover83 was talking about and fixed them. –b-rad >>>

April 10th, 2009 10:27

Excellent tutorial …

Is is possible for you to change the background of your website to white and use a little bigger fonts … It is bit hard to read …

<<< edit: My eyes like light text on dark background, so no, and any modern browser should allow zooming of text size, in firefox its ctrl^+/- –b-rad >>>

April 10th, 2009 12:53


Maybe you need your eyes checked or perhaps a new monitor. I have no problems with this website.

April 10th, 2009 21:41

Hi guys,

I tried this tutorial part1, 2 and now the wtorrent guide.

I have completed all steps except I have no /opt/share/www/index.php

To get any wtorrent gui I have to use this address

The next funny thing is that it asks me for a wtorrent password and username and I’m not talking about the htpasswd prompt…it’s the actual gui asking for a username and password.

If I click login it just goes blank.

Any clues guys?



April 10th, 2009 21:42

BTW I applied the fix that takinover83 suggested also to get to this point. Before that I wasn’t getting anything at all.

April 10th, 2009 22:05

Gee I’m really giving this tutorial a thorough work over.

Here’s what I’ve found :

To configure the installation I had to manually go to : http:/mywdtvipaddress:8081/wtorrent/install.php

Secondly when I tried to “Try Configuration” it would give me an error about not being able to reach rtorrent etc…” this was because the rtorrent’s init.d script was buggy so I used the one posted by realtbo here : http://www.mirkotebaldi.it/S99rtorrent-correct.txt

Config tested fine and am saving now.

Will post back if I find anything else.



< << edit: Thanks for pointing that out steve, I've edited the writeup to indicate you must browse to the install page. This I imagine takes care of the blank page scenario takenover and others have described. Thats sort of a big detail I left out :)

As well realtbo's init.d modification is not ideal. It might work, but its more a temporary hack. If I can find the time I will patch the Optware package.

--b-rad >>>

May 3rd, 2009 06:10

Good work !
I’ve limited knowledge of telnet/linux and have got quite far through this tutorial but now when I telnet in and type a command (ie ipkg update) I get a message ‘SIGUSR1′ – how do I stop this happening ?

<<< edit: dunno, haven’t seen that myself. I see you’ve posted at wdtvforum.com about it, perhaps someone there will know. –b-rad >>>

May 17th, 2009 05:34

Hi B-Rad,

thanks for excellent work!

Do you have any idea why does rtorrent quits/crashes after some time? I just added 1 torrent to download, ~800MB size, wtorrent shows download in progress, but after some time, when i click refresh in wtorrent, it shows “Error: cannot connect to rtorrent”. When i check ps on wdtv, i cannot see rtorrent running and i need to restart it.
Any ideas would be appreciated.

Thanks again!

June 5th, 2009 04:43

Great Tutorial.
I’ve been able to go through the tutorial, but now when i add a torrent i get this message:
Storage error: [File chunk write error: No such device]
Help needed…

<<< edit: Think I’ve seen this when using an NTFS filesystem. –b-rad >>>

June 13th, 2009 02:41

I would really like to try it but it doesn’t work for me. Everything looks fine except the last part.

# htpasswd b-rad.cc wtorrent.on.wdtv testing >> \

I tried everything but this line is kinda tricky. i don’t know how to type it in….. simple copy and paste doesn’t work here

pls someone, i need help

<<< edit: You’re not typing the # are you? –b-rad >>>

June 24th, 2009 02:34

No, no, no :) otherwise i wouldn’t accomplish 99% of this tutorial :)

so i type in “htpasswd b-rad.cc wtorrent.on.wdtv testing >> \ /opt/etc/lighttpd/.passwd”

it says “no such applet” or something like this…

any idea?

<<< edit: the line should be:

htpasswd b-rad.cc wtorrent.on.wdtv testing >> /opt/etc/lighttpd/.passwd

backslash is a line continuation statement, if all on one line you don’t need it. –b-rad >>>

June 24th, 2009 18:46

I had to change something in:

change every occurrence of:

I was getting the error:
“Impossible to create file on given directory, please check permisions.”

I found the fix in wtorrent project Ticket #104.

June 26th, 2009 20:35


Awesome work! Everything went smooth for me except the rtorrent startup script. I did use the modified version which works if I just run it from console (/opt/etc/init.d/S99rtorrent-correct). The correct script does not work on starting/rebooting the device. After rebooting, if I try screen -r in the console, all I get is a terminal with the session directory /opt/share/torrent active. Comments?

Thanks a lot for your efforts.

<<< edit: try and run rtorrent without screen importing your config file manually the first time. After that it should work using screen -r rtorrent. –b-rad >>>

July 9th, 2009 13:28

Thanks B-rad,

Great work..Followed it all .. but now getting the error “Error: could not connect to rtorrent ”

Any hints..?


July 9th, 2009 14:59

Did it again and its working fine now thanks.. :)


August 7th, 2009 17:31

# htpasswd b-rad.cc wtorrent.on.wdtv testing >> /opt/etc/lighttpd/.passwd

htpasswd: applet not found

Any ideia wath is it?

I can’t fix it :(

# htpasswd
htpasswd: applet not found

<<< edit: did you make the script like instructed a few lines below? –b-rad >>>

September 7th, 2009 09:32

Why not just use Torrentfulx… its available in optware.

It does it all.


<<< edit: perhaps because torrrentflux wasn’t in the feed when I wrote this? –b-rad >>>

September 14th, 2009 11:07

To Oga:
I too got the “no such applet” error.

It was because I had spaces in the “/opt/bin/htpasswd” file we created. Make sure there are no spaces in front of “#!/bin/sh”.

September 18th, 2009 02:58

I Have same Problem.

wtorrent say “Error: could not connect to rtorrent ”
rtorrent is starting.

Any Idea?

<<< edit: check your settings. –b-rad >>>

November 20th, 2009 06:47

is there an encryption option? my isp throttles torrents and makes it impossible to download anything if I do not have encryption enabled. i have not purchased a media player b/c i am trying to find one with all the features i would like. a torrent option is great but i need encryption to bypass my isp.

<<< edit: Theres encryptions options in rtorrent.conf, read up on it and set them accordingly. –b-rad >>>

April 10th, 2010 02:39

I have some problems when I’ve tried to add a new torrent.
The wtorrrent keep telling me that the torrent file is not a torrent file.

I looked into source code and I’ve observed that in AddT file, in function addRemoteTorrent, the first 13 charcters are read in buffer and then looking for “announce” string, which is actually present in the torrent file.

How can we avoid this situation without modifiying the source code and building?

Thanks in advance.

<<< edit: wtorrent has absolutely nothing to do with me, go ask them ;) –b-rad >>>

June 19th, 2010 19:41

Hi B-Rad,

Excellent tutorial.

I was able to do everything until I start getting ’500 – Internal Server Error’ when I call the install.php page (http://my_wdlxtv_ip:8081/wtorrent/install.php). It was working before trying put wTorrent to work.

The error that I am getting in the lighttpd error log is:

2010-06-20 03:38:10:(mod_fastcgi.c.2816) child signaled: 11
2010-06-20 03:38:11:(mod_fastcgi.c.2582) unexpected end-of-file (perhaps the fastcgi process died): pid: 23985 socket: unix:/tmp/php-fcgi.sock-4
2010-06-20 03:38:11:(mod_fastcgi.c.3367) response not received, request sent: 938 on socket: unix:/tmp/php-fcgi.sock-4 for /wtorrent/install.php?, closing connection

Did anyone had this same problem.

August 5th, 2010 08:26

when i do ipkg update i get this error:

# ipkg update
Downloading http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//Packages.gz

wget: can’t handle reloc type 0x2f
An error ocurred, return value: 1.
Collected errors:
ipkg_download: ERROR: Command failed with return value 1: `wget -q -P /opt/ipkg-B709fu http://ipkg.nslu2-linux.org/feeds/optware/wdtv/cross/unstable//Packages.gz

<<< edit: What platform are you trying this on? This is only for the original WDTV, not Gen2 or Live. Post your finding and further information at forum.wdlxtv.com. –b-rad >>>

June 3rd, 2011 23:04

wtorrent website does not have the build. Can anyone upload it somewhere ? Google was of no help. Appreciate your help.

June 10th, 2011 09:24

I got wtorrent-current.zip from the following link instead of the link given in the article. Hope this helps someone.