Skip to content
MichaIng edited this page Dec 9, 2021 · 19 revisions

Webserver Setup

Basic points

  • ruTorrent is written in JavaScript and PHP, so your webserver must be setup for PHP.
  • PHP requires mbstring extension (not enabled by default in PHP).
  • ruTorrent communicates with rtorrent via an SCGI gateway. For this you need:
  • There are multiple ways to configure a webserver, this page is not meant as a all inclusive guide.

SCGI setup

Most webservers have some sort of SCGI module. For lowest server load, it's best to use a SCGI module. For lowest bandwidth clients, however, it's best to use HTTPRPC Plugin (this is not an option for very slow computers, or embedded systems).

Also, a note on authentication. If you are password protecting your ruTorrent directory, make sure to set your SCGI mount point under that directory, or provide authentication for it as well.

Lighttpd Specific SCGI Config

Lighttpd is a very light and simple webserver and require only a very rapid configuration.

RPC SOCKET

If you are using rpc socket (Recommended), edit lighttpd.conf (Usually in /etc/lighttpd/lighttpd.conf) in this way.

  1. Please search and install also this packages on your system:
php-cgi, php-fpm
  1. Make sure that server.modules contains mod_fastcgi:
server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_fastcgi",
)
  1. Add fastcgi.server server section:
fastcgi.server = ( ".php" => ((
                 "bin-path" => "/usr/bin/php-cgi",
                 "socket" => "/tmp/php.socket"
)))
  1. Don't forget do edit ruTorrent config file to enable rpc socket insted rpc host and port.

RPC host and port

If you are using RPC host and port (Old behavior), edit lighttpd.conf (Usually in /etc/lighttpd/lighttpd.conf) in this way.

  1. Make sure that server.modules contains mod_scgi:
server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_scgi",
)
  1. Add scgi.server as shown below:
scgi.server = (
        "/RPC2" =>
                ( "127.0.0.1" =>
                        (                
                                "host" => "127.0.0.1",
                                "port" => 5000,
                                "check-local" => "disable"
                        )
                )
        )

For multiple SCGI mounts, you'd add something like this:

scgi.server = (
                "/RPC1"=>
                (
                        "127.0.0.1" =>
                        (
                                "host" => "127.0.0.1",
                                "port" => 5001,
                                "check-local" => "disable"
                        )
                ),
                "/RPC2"=>
                (
                        "127.0.0.1" =>
                        (
                                "host" => "127.0.0.1",
                                "port" => 5002,
                                "check-local" => "disable"
                        ),
                "/RPC3"=>
                (
                        "127.0.0.1" =>
                        (
                                "host" => "127.0.0.1",
                                "port" => 5003,
                                "check-local" => "disable"
                        ),
                "/RPC4"=>
                (
                        "127.0.0.1" =>
                        (
                                "host" => "127.0.0.1",
                                "port" => 5004,
                                "check-local" => "disable"
                        )
                )
)

It's important to note the comma between each section.

Apache Specific SCGI Config

Apache doesn't come with mod_scgi, you need to install it. This is different for each distro, for Ubuntu/Debian it is:

apt-get install libapache2-mod-scgi

for FreeBSD,

cd /usr/ports/www/mod_scgi && make install clean

(some distros require you to enable this module manually, consult your distro for specific information about loading Apache modules).

Once you have mod_scgi installed and loaded, adding SCGI mounts is almost trivial.

add something like this for each mount:

SCGIMount /RPC2 127.0.0.1:5000

Mod Proxy SCGI

Recently, I have found this module. In some situations this might be a better fit (though i have no idea of the performance differences between mod_scgi and mod_proxy_scgi) On OpenSolaris, for instance, there is no mod_scgi package, but mod_proxy_scgi comes with the default Apache config.

It's very simple to use, just add a directive like:

ProxyPass /RPC2 scgi://localhost:5000/

or

ProxyPass /RPC2 unix:/path/to/unix.socket|scgi://127.0.0.1

Cherokee Specific SCGI Config

Cherokee makes everything really easy if you use cherokee-admin. To add an SCGI mount in cherokee, simply select your virtual server (the default server is fine, or you could create one specifically for ruTorrent), select the "behavior" tab as show in this screenshot:

Then select "wizards" and "misc" as shown in this screenshot:

Then select the rtorrent wizard, and set it accordingly, as shown here:

(note: you add PHP to cherokee in almost the exact same way, except instead of "misc/rtorrent" select "languages/php").

If you don't use cherokee admin, it might look something like this:

vserver!20!rule!500!disabled = 1
vserver!20!rule!500!handler = scgi
vserver!20!rule!500!handler!balancer = round_robin
vserver!20!rule!500!handler!balancer!source!1 = 11
vserver!20!rule!500!match = request
vserver!20!rule!500!match!final = 1
vserver!20!rule!500!match!request = ^/RPC1

Nginx SCGI notes

Nginx 0.8.42 and newer has a SCGI module. It's enabled by default when you build nginx. It's config options are fairly simple.

location /RPC2 {
  include scgi_params;
  scgi_pass localhost:5000;
}

For more info, see Nginx SCGI docs

Clone this wiki locally