The previous article about the rtorrent + rutorrent + nginx + php-fpm bundle was written right after a successful installation and initial configuration of this bundle. During operation, some pitfalls emerged, which I want to talk about.
RPC
As it turned out, the nginx bundle with rutorrent + rtorrent worked fine, just write the following lines in the
conf / config.php file in the rutorrent installation directory tree:
$scgi_port = 33333;
$scgi_host = "127.0.0.1";
At the same time, it is enough to register the network socket in the rtorrent
~ / .rtorrent.rc file:
')
scgi_port = 127.0.0.1:33333
In nginx, you no longer need to write backend for / RPC2, and from the rtorrent startup scripts you need to remove work with a local UNIX socket to control rtorrent.
Access rights
Naturally, in order for rutorrent to work successfully, you need the user, on behalf of which the nginx and php-fpm daemons work, to grant rights to all the files and directories of the rutorrent installation. In my case, this is done by the command:
sudo chown -R http:http /srv/http/nginx/rutorrent.eternity/htdocs
Php-fpm socket
When using php-fpm locally, it is better to put it on a UNIX socket. To do this,
you need to comment out the line with the network socket in the
/etc/php/php-fpm.conf file:
;listen = 127.0.0.1:9000
And enter the line with a UNIX-socket below:
listen = /var/run/php-fpm/php-fpm.sock
After that, you need to reconfigure nginx. In the
/etc/nginx/conf/nginx.conf file,
we bring the backend block to this form:
upstream backend { server unix:/var/run/php-fpm/php-fpm.sock; }
Using UNIX sockets reduces the load on the system, since checksums are not calculated, and the data stream is sent directly to the receive buffer. Critical for embedded solutions only.
Security
When using nginx locally, it is best to land on 127.0.0.1. To do this, in the
/etc/nginx/conf/sites-enabled/rutorrent.eternity file
, the line of
listen should be reduced to the following form:
listen 127.0.0.1:80;
If this is not done, the web interface can be used by someone who knows the IP address of the computer. To be able to remotely control rtorrent, you should take care of authentication (at least through the basic nginx authentication).
geoip
In order for the rutorrent module called geoip to work, you need to install the appropriate extension for PHP. In my case (
Arch Linux ) this action looks like this:
sudo pacman -S php-geoip
Then in the
/etc/php/conf.d/geoip.ini file
you need to remove the comment from a single line so that it looks like this:
extension=geoip.so
You also need to activate the JSON plugin. This is done by creating a
json.ini file in the
/etc/php/conf.d directory with the following contents:
extension=json.so
Without the json plugin, nothing will work.
Auxiliary programs
In order for rutorrent to find additional programs (
curl, stat, mediainfo ), first, they need to be installed:
sudo pacman -S curl mediainfo
Secondly, it is necessary to allow their execution. To do this, you need to comment out the open_basedir line in the
/etc/php/php.ini file:
;open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/
And, thirdly, additional programs are required to be registered in the rutorrent configuration. CURL and stat are written in the
conf / config.php file of the rutorrent installation directory tree as follows:
$pathToExternals = array( "php" => '', "curl" => '/usr/bin/curl', "gzip" => '', "id" => '', "stat" => '/usr/bin/stat', );
The path to the mediainfo program is specified in the
plugins / mediainfo / conf.php file of the
rutorrent installation directory tree as follows:
$pathToExternals['mediainfo'] = '/usr/bin/mediainfo';
These paths can also be omitted if the PATH environment variable is set for the user on whose behalf daemon web part daemons are set.
Yummy
For myself, I made a script with the following contents:
#!/usr/bin/env bash delay="1000" pid1=`pidof rtorrent` if [[ $pid1 != "" ]] then notify-send -t $delay " rtorrentd…" sudo rc.d stop rtorrentd notify-send -t $delay "rtorrentd " else notify-send -t $delay " rtorrentd…" sudo rc.d start rtorrentd notify-send -t $delay "rtorrentd " fi
This script is granted permissions to execute:
sudo chown root:root x-rtorrentd-wrapper.sh
sudo chmod 755 x-rtorrentd-wrapper.sh
The script itself is moved to
/ usr / bin :
sudo mv x-rtorrentd-wrapper.sh /usr/bin
Then somewhere on the panel of your DE (
I did everything in xfce ) a button is hung up to launch this script. If rtorrent is not running, the script will launch it, and if it is running, it will turn it off, while displaying a pop-up notification on the screen via libnotify. Of course, for this you need to install libnotify:
sudo pacman -S libnotify
Restart daemons
After performing all the above actions, you need to restart php-fpm and nginx:
sudo rc.d restart php-fpm nginx
As a result, the chances that the rutorrent will fully earn will increase substantially.
UPDATE 1: added some explanation.
UPDATE 2: updated partition with RPC. Thank you
svin0 .