Messy article, but let’s try to summarise a bit.
We’re going to run a very lightweight Torrent client setup, with graphical interface, on a Debian server (an old raspberry pi, to be precise).
Install rtorrent
apt-get install rtorrent
Configure rtorrent to run as a service
Configure user
Let’s create a user torrent
to run the rtorrent service
useradd -m -d /var/torrent torrent
Create the service
Create the file /etc/systemd/system/rtorrent.service
[Unit] Description=rTorrent Daemon After=network.target [Service] [Unit] Description=rTorrent Daemon After=network.target [Service] Type=simple KillMode=process User=torrent ExecStartPre=/bin/bash -c "if test -e /var/torrent/rtorrent/.session/rtorrent.lock && test -z pidof rtorrent; then rm -f /var/torrent/rtorrent/.session/rtorrent.lock; fi" ExecStart=/usr/bin/rtorrent WorkingDirectory=/var/torrent/rtorrent Restart=on-failure [Install] WantedBy=multi-user.target
Enable the service
systemctl enable rtorrent
Configure rtorrent for user torrent
As root su - torrent
to become torrent user. Then run the following oneliner: (ref. CONFIG Template ยท rakshasa/rtorrent Wiki ยท GitHub)
curl -Ls "https://raw.githubusercontent.com/wiki/rakshasa/rtorrent/CONFIG-Template.md" \ | sed -ne "/^######/,/^### END/p" \ | sed -re "s:/home/USERNAME:$HOME:" >~/.rtorrent.rc mkdir -p ~/rtorrent/
Edit your new .rtorrent.rc
file accordingly as per below:
# Some extra parameters dht.mode.set = auto dht_port = 6881 protocol.pex.set = yes trackers.use_udp.set = yes # This will run XMLRPC interface (disabling manual/text mode version) system.daemon.set = true scgi_port = 127.0.0.1:5000
Note that port 50000 is the default one that you should open/forward on/from your router.
Install Lighttpd
Let’s install the basic, setting right permissions
apt-get install lighttpd php-cgi lighty-enable-mod fastcgi lighty-enable-mod fastcgi-php # Get latest ruTorrent package and install cd /var/www/html/ git clone https://github.com/Novik/ruTorrent.git chown-R www-data:www-data /var/www/ service lighttpd force-reload
Verify creating a page called test.php
into /var/www/html/
with the content <?php phpinfo(); ?>
and check in the browser if it works. It should. If not… tough life ๐
Web configuration file for rTorrent: /etc/lighttpd/conf-available/20-rtorrent
server.modules += ( "mod_fastcgi" ) server.modules += ( "mod_scgi" ) mimetype.assign = ( ".rpm" => "application/x-rpm", ".pdf" => "application/pdf", ".sig" => "application/pgp-signature", ".spl" => "application/futuresplash", ".class" => "application/octet-stream", ".ps" => "application/postscript", ".torrent" => "application/x-bittorrent", ".dvi" => "application/x-dvi", ".gz" => "application/x-gzip", ".pac" => "application/x-ns-proxy-autoconfig", ".swf" => "application/x-shockwave-flash", ".tar.gz" => "application/x-tgz", ".tgz" => "application/x-tgz", ".tar" => "application/x-tar", ".zip" => "application/zip", ".mp3" => "audio/mpeg", ".m3u" => "audio/x-mpegurl", ".wma" => "audio/x-ms-wma", ".wax" => "audio/x-ms-wax", ".ogg" => "application/ogg", ".wav" => "audio/x-wav", ".gif" => "image/gif", ".jar" => "application/x-java-archive", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".png" => "image/png", ".xbm" => "image/x-xbitmap", ".xpm" => "image/x-xpixmap", ".xwd" => "image/x-xwindowdump", ".css" => "text/css", ".html" => "text/html", ".htm" => "text/html", ".js" => "text/javascript", ".asc" => "text/plain", ".c" => "text/plain", ".cpp" => "text/plain", ".log" => "text/plain", ".conf" => "text/plain", ".text" => "text/plain", ".txt" => "text/plain", ".dtd" => "text/xml", ".xml" => "text/xml", ".mpeg" => "video/mpeg", ".mpg" => "video/mpeg", ".mov" => "video/quicktime", ".qt" => "video/quicktime", ".avi" => "video/x-msvideo", ".asf" => "video/x-ms-asf", ".asx" => "video/x-ms-asf", ".wmv" => "video/x-ms-wmv", ".bz2" => "application/x-bzip", ".tbz" => "application/x-bzip-compressed-tar", ".tar.bz2" => "application/x-bzip-compressed-tar", # default mime type "" => "application/octet-stream", ) scgi.server = ( "/RPC2" => ( "127.0.0.1" => ( "host" => "127.0.0.1", "port" => 5000, "check-local" => "disable" ) ) ) fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php-cgi", "socket" => "/tmp/php.socket" )))
Enable the configuration linking and reload lighttpd
ln -sf /etc/lighttpd/conf-available/20-rtorrent /etc/lighttpd/conf-enable/20-rtorrent systemctl reload lighttpd
Now, if all went well, you should be able to start the rtorrent service
systemctl start rtorrent
…and theoretically, even open ruTorrent in your browser.
ruTorrent, currently is configured by default to connect to 127.0.0.1:5000. You can change these parameters within its config.php file.
However, we used the default settings in this how to, and you should be able to have it working simply…
http://<ip_of_your_raspberry_pi>/ruTorrent/
Give it a try… and good luck! ๐