[solved] Rutorrent on OpenWrt

anyone here familiar with rutorrent on openwrt?
I have rtorrent up and runnign more or less.
but when I run rutorrent I get the error that
"[19.02.2019 12:02:30] history: Plugin will not work. rTorrent user can't access external program (php)."
and for other plugins too.
both rtorrent and uhttpd (or lighttpd ,I tested with that too) ,are running as root.
any idea how to fix this?
the torrent and rutorrent and data are stored on a usb attached hdd and with root owner and all access permission.

Have you pursued that?

As something of an aside, PHP and PHP-based apps don't have a great track record around security and robustness. I personally wouldn't be running it a user with any significant level of privilege on a security-critical device like a firewall/router. Yes, you can configure additional users on OpenWrt, but it is perhaps a lot easier to install public services like this on another device.

found the issue.
I thought it was permission related but it was because php is not available in openwrt in as a "php" binary file but as php-cgi or php-cli.
changing the php path in rutorrent/cong/conf.php to php-cgi path fixed it.

about the second part, unfortunately I read that I have to run the uhttpd as root (which is the default behavior) and it seems that I need to run rtorrent as the same user,(I think because of permission issues).

even if I did add a rtorrent user I don't know which user would use php(which user would invoke it) . rtorrent one or rutorrent one(root one). but my guess is the uhttpd would use it when I interact with rutorrent so that one is root.
unless I can run the rutorrent server(which is right now added on a port other that 80 in additional secton the uhttp.conf) ,then i think php would run as root.

I always try to restrict as much as I can but because I have come close to bricking my router (and did brick it twice ,but luckily it has a partition for recovery and an easy recovery move) I cant play with uhttpd and then later find out that I cant access my router or install apps or so on.
if you have any experience with this ,please share.

maybe I try to experiment later but right now I am just setting my rtorrent and it takes times to migrate the torrent from my pc to openwrt.


Did you manage to run rutorrent? Will it open in the browser?

yes I have it running.
sometimes it says it rtorrent user cant find the php stat and id programs.
but most times it works.
need help?

i used the php-cgi and uhttpd and it works.

Yes, you can share which packages were installed, and the configuration settings rtorrent xmlrpc rutorrent.
I will use the nginx web server, here I will try to figure it out myself.
if it works out with the rights then I will share !

I first used lightttd but realized that the default uhttpd worked.
I have the lighttpd configs but I think it didnt work completely.
I recommend using uhttpd for now.

I made these changes.
1- uhttpd config inside /etc/config/

config uhttpd 'rutorrent_seeding'
list interpreter '.php=/usr/bin/php-cgi'
option listen_http '1081'
option home '/path to root of rutorrent on my usb hdd drive/ruTorrent/'

2- installed these
"gzip php7-mod-json php7-cgi php7-mod-zip"

3 changed php path in rutorrent/conf/config.php to the path of php-cgi .
I tested and php-cli didn't work so I used php-cgi (I am not pro with php, specially on openwrt that it seems to have split php binary into some binaries).

4 in /etc/php.ini I commented out the working directory so that php has access to all the files.
this is insecure (I think so) but I don't have the time to fix this for now).

5 for rtorrent you configure it like rtorrent on a normal computer (if you are not familiar ask and I will put that too)

6- give write and read access to all (or maybe just regular user and web user) to the download directory rutorrent share directory .


for rtorrent just install rtorrent-rpc.
for rtorrent config , that depends on your needs but the only part that is needed for using it with rutorrent is these two which you use one of them.

network.scgi.open_port =
network.scgi.open_local = /tmp/rtorrent-seeding.socket

the first on uses networks connections to connect to rutorrent and the second one uses a socket file.(I use the second one and I put the socket in /tmp ram)

you need to change the config of rutorrent accordingly in this part:
// $scgi_port = 5001;
//$scgi_host = "";
$scgi_host = "unix:///tmp/rtorrent-seeding.socket";

as you can see I commented out the network choice and went with the socket file.

but these all are available on internet and are not related to openwrt.
if you are familiar with rutorrent and rtorrent from before you just need the 4 parts i mentioned.

btw I run rtorrent for seeding and downloading (with two instances) and the seeding one with 800 torrents (big and small but mostly small files) uses 130 mB ram.

Thanks for your walk trough!!!

Unfortunately I am missing something. I am getting:
"Bad response from server: (500 [error,getplugins]) Internal Server Error"

can you clarify these two things:



i usually cant get rutorrent to work at all in first try and it almost has many issues that are need to be fixed before it works on different platforms.
I no longer use it on openwrt.

but these are some points that I can write for you.
use the same user (root) first for all services that u run for this to work then later change rtorrent user to a non-root for security. this way you know the errors are not permission related.

for your first question you can search google for answer but the short answer is https://www.php.net/manual/en/ini.core.php#ini.open-basedir

the second question that is more important to fix is that it seemed that on openrt the php binary that works is php-cgi not the vanilla php name.
so in this files (in rutorrent directory) ruTorrent/conf/config.php change these to complete path of the binaries on your openwrt system

$pathToExternals = array(
"php" => '/usr/bin/php', // Something like /usr/bin/php. If empty, will

but for php dont use php but php-cgi like this
"php" => '/usr/bin/php-cgi',
or whatever the address of php-cgi is on your system.

the last question is related to my first point about root access.
use root first for all and then if it works correctly I will help you with creating a non-root user and using that for download (more secure this way)

are you using a different client on OpenWRT?

I no longer download on opewnrt router.
there is also transmission on openwrt that I also tested on openwrt and it is simpler than rtorrent.

but fair warning I have a linksys with 500MB RAM

rtorrent is a bittorrent client. rutorrent is a website.

rutracker is a website.
rutorrent in an html interface for rtorrent.

1 Like

Hello there.
I know that I'm now like an archaeologist but I need help from this community.

Well I have problem with ruTorrent - I'm still getting an error like this:
https://i.imgur.com/fh6Iw9C.png and after trying to add torrent I get also : " JS error: [ : 0] Script error."

I did everything in a turn like here: https://eko.one.pl/forum/viewtopic.php?pid=188347#p188347
but my php packets are php8 not 7, and my rutorrent version is 3.10
I have also problem with chown -R http.www-data /www/rutorrent - I'm getting error like this: "chown: unknown user/group http:www-data"
My server is uHTTPpd.

Can someone help me track and resolve my problem?
Would be very appreciated

the second issue it that on openwrt uhttpd server runs as root, but on other linux system people don't run servers at root and run them as a separate user like http and assign that user to www-data group. so instead of root:root you would use http:www-data.

my suggestion is NOT to use any other user other than root.
I know this is insecure but this way you don't get errors like you got for permissions and non existent users.
if all that works with root user then you can create new users and run rtorrent as that and move permissions to that user.

Hi again,
I did factory reset.
Now I have:

OpenWrt 22.03-SNAPSHOT r19385-f765f2f114
rtorrent rpc 0.9.8-2
rutorrent v4.0-beta.2.1

and i still get this error https://i.imgur.com/4Fl1Guo.png

I'm completely helpless, really don't know what I'm doing wrong.
Any help would be appreciated, thank You.

first, use the stable rutorrent version not the beta one. usually (specially in web apps) changes from one version to another, needs changes to configs and tutorials that you use.

when you ask for help for computer problems, specially linux issues which can be reproduced from command line, it is almost mandatory to explain what you did step by step.
for commands, it is also mandatory to type them here too so that community can see what you did to get to that point. and give you commands to run.

use code( called "Preformatted text" here, shown as </>) icon to enclose the commands, like so:

rtorrent -c ./configfile

also helpers may ask you to paste your config files here too (if they have personal info in them, like name, you can blank those)

@reza You can't imagine, how happy I was, when i saw the reply to my post.

Ok, so step by step:

I've replaced rutorrent for latest 3.10 version.
I did everything like here: https://eko.one.pl/forum/viewtopic.php?pid=188347#p188347

but, my php packets which I've installed are php8, and as far as I'm concered package **php8-mod-json is internal part of php8 package, so it couldn't be install as seperate part.

opkg install rtorrent-rpc screen php8 php8-cgi

my rtorrent.rc file:

# ~/.rtorrent.rc and enable/modify the options as needed. Remember to
# uncomment the options you wish to enable.

# Maximum and minimum number of peers to connect to per torrent.
throttle.min_peers.normal.set = 40
throttle.max_peers.normal.set = 100

# Same as above but for seeding completed torrents (-1 = same as downloading)
throttle.min_peers.seed.set = 10
throttle.max_peers.seed.set = 50

# Maximum number of simultanious uploads per torrent.
throttle.max_uploads.set = 15

# Global upload and download rate in KiB. "0" for unlimited.
throttle.global_down.max_rate.set_kb = 0
throttle.global_up.max_rate.set_kb = 0

# Default directory to save the downloaded torrents.
directory.default.set = /home/files

# Default session directory. Make sure you don't run multiple instance
# of rtorrent using the same session directory. Perhaps using a
# relative path?
session.path.set = ~/.rtorrent.session

# Watch a directory for new torrents, and stop those that have been
# deleted.
#schedule2 = watch_directory,5,5,load.start=./watch/*.torrent
#schedule2 = untied_directory,5,5,stop_untied=

# Close torrents when diskspace is low.
#schedule2 = low_diskspace,5,60,close_low_diskspace=100M

# The ip address reported to the tracker.
#network.local_address.set =
#network.local_address.set = rakshasa.no

# The ip address the listening socket and outgoing connections is
# bound to.
#network.bind_address.set =
#network.bind_address.set = rakshasa.no

# Port range to use for listening.
network.port_range.set = 62000-64999

# Start opening ports at a random position within the port range.
network.port_random.set = no

# Check hash for finished torrents. Might be usefull until the bug is
# fixed that causes lack of diskspace not to be properly reported.
pieces.hash.on_completion.set = no

# Set whether the client should try to connect to UDP trackers.
trackers.use_udp.set = yes

# Alternative calls to bind and ip that should handle dynamic ip's.
#schedule2 = ip_tick,0,1800,ip=rakshasa
#schedule2 = bind_tick,0,1800,bind=rakshasa

# Encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
# The example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
 protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext

# Enable DHT support for trackerless torrents or when all trackers are down.
# May be set to "disable" (completely disable DHT), "off" (do not start DHT),
# "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
# The default is "off". For DHT to work, a session directory must be defined.
# dht.mode.set = auto

# UDP port to use for DHT.
dht.port.set = 6881

# Enable peer exchange (for torrents not marked private)
protocol.pex.set = yes

system.umask.set = 0000
session.use_lock.set = no
network.scgi.open_local = /tmp/rpc.socket
schedule2 = scgi_permission,0,0,"execute.nothrow=chmod,777,/tmp/rpc.socket"

rutorrent config:

        // configuration parameters

        // for snoopy client
        @define('HTTP_USER_AGENT', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36', true);
        @define('HTTP_TIME_OUT', 30, true);     // in seconds
        @define('HTTP_USE_GZIP', true, true);
        $httpIP = null;                         // IP string. Or null for any.
        $httpProxy = array
                'use'   => false,
                'proto' => 'http',              // 'http' or 'https'
                'host'  => 'PROXY_HOST_HERE',
                'port'  => 3128

        @define('RPC_TIME_OUT', 5, true);       // in seconds

        @define('LOG_RPC_CALLS', false, true);
        @define('LOG_RPC_FAULTS', true, true);

        // for php
        @define('PHP_USE_GZIP', false, true);
        @define('PHP_GZIP_LEVEL', 2, true);

        $schedule_rand = 10;                    // rand for schedulers start, +0..X seconds

        $do_diagnostic = true;
        $log_file = '/tmp/errors.log';          // path to log file (comment or leave blank to disable logging)

        $saveUploadedTorrents = true;           // Save uploaded torrents to profile/torrents directory or not
        $overwriteUploadedTorrents = false;     // Overwrite existing uploaded torrents in profile/torrents directory or make unique name

        $topDirectory = '/';                    // Upper available directory. Absolute path with trail slash.
        $forbidUserSettings = false;

        //$scgi_port = 5000;
        //$scgi_host = "";

        // For web->rtorrent link through unix domain socket
        // (scgi_local in rtorrent conf file), change variables
        // above to something like this:
        $scgi_port = 0;
        $scgi_host = "unix:///tmp/rpc.socket";

        $XMLRPCMountPoint = "/RPC2";            // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!

        $pathToExternals = array(
                "php"   => '/usr/bin/php-cgi',                  // Something like /usr/bin/php. If empty, will be found in PATH.
                "curl"  => '',                  // Something like /usr/bin/curl. If empty, will be found in PATH.
                "gzip"  => '',                  // Something like /usr/bin/gzip. If empty, will be found in PATH.
                "id"    => '',                  // Something like /usr/bin/id. If empty, will be found in PATH.
                "stat"  => '',                  // Something like /usr/bin/stat. If empty, will be found in PATH.

        $localhosts = array(                    // list of local interfaces

        $profilePath = '../share';              // Path to user profiles
        $profileMask = 0777;                    // Mask for files and directory creation in user profiles.
                                                // Both Webserver and rtorrent users must have read-write access to it.
                                                // For example, if Webserver and rtorrent users are in the same group then the value may be 0770.

        $tempDirectory = null;                  // Temp directory. Absolute path with trail slash. If null, then autodetect will be used.

        $canUseXSendFile = false;               // If true then use X-Sendfile feature if it exist

        $locale = "UTF8";

and my rutorrent plugins.ini:

;; Plugins' permissions.
;; If flag is not found in plugin section, corresponding flag from "default" section is used.
;; If flag is not found in "default" section, it is assumed to be "yes".
;; For setting individual plugin permissions you must write something like that:
;; [ratio]
;; enabled = yes                        ;; also may be "user-defined", in this case user can control plugin's state from UI
;; canChangeToolbar = yes
;; canChangeMenu = yes
;; canChangeOptions = no
;; canChangeTabs = yes
;; canChangeColumns = yes
;; canChangeStatusBar = yes
;; canChangeCategory = yes
;; canBeShutdowned = yes

enabled = user-defined
canChangeToolbar = yes
canChangeMenu = yes
canChangeOptions = yes
canChangeTabs = yes
canChangeColumns = yes
canChangeStatusBar = yes
canChangeCategory = yes
canBeShutdowned = yes

enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = user-defined
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = no
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = yes
enabled = no
enabled = yes
enabled = yes

I think its all of information I can give You right now.
When You need anything else, I'm here. Thank You.

it doesnt mean me or others will help.
it means we are more likely to help this way.

why do you use that guide? it is up to date?
I cant read it.
are you sure you replaced rutorrent with the stable one and still get the same error?

stop running rtorrent and run the web server alone and see if error is the same.
are you familiar with screen command?

screen -dmSfn rtorrent rtorrent

this runs rtorrent in background.
do not use it right now.
use two terminals and run rtorrent in forground. this is for debugging purposes.

also when you change uhttpd config do you remember to restart its service?
I ask these because I dont know how familiar with linux and openwrt in general.

btw it you have matrix or something like that I can maybe help faster online instead of waiting for responses here.

P.S. frankly your error seems like a config error.
as in you copied and pasted from web and it missed a letter.