Hi,
I've been trying to setup rutorrent with nginx. Since most of the tutorials I found are either with apache or are outdated nginx tutorials (no plugin rpc/httprpc), I've been struggling to get this work on my own (mainly due to my limited knowledge of linux).
My main aim is to reduce the memory usage as much as possible. So, instead of targeting some high end seedbox setup, I'm more inclined towards getting this work with low end VPS.
Any help would be appreciated in putting this whole as a proper working tutorial.
So far, I've done the following (currently tried this on Ubuntu 12.10):
Installed nginx via apt-get. (Q: Should we build/compile nginx on our own using "--without-http_scgi_module"? or it wouldn't make any difference if we later on use rutorrent plugin?)
Code:
apt-get install nginx
Installed PHP-FPM & PHP-CLI (I assume rutorrent require CLI)
Code:
apt-get install php5-fpm php5-cli
Edited nginx config to update the worker processes (equal to processor cores)
Code:
nano /etc/nginx/nginx.conf
[...]
worker_processes 1;
[...]
Created www directory in /var for website data
Code:
mkdir /var/www
Added a new website for rutorrent & enabled it by creating a symbolic link
Code:
nano /etc/nginx/sites-available/rutorrent
Code:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /var/www; ## Changed from : /usr/share/nginx/www
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Code:
cd /etc/nginx/sites-enabled
ln -s ../sites-available/rutorrent
/etc/init.d/nginx reload
/etc/init.d/nginx restart
Edited PHP-FPM config to reduce the number of process & changed the spawning to ondemand (depending on the server specs, for low memory use?)
Code:
nano /etc/php5/fpm/pool.d/www.conf
[...]
pm = ondemand
pm.max_children = 2
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.process_idle_timeout = 5s
[...]
/etc/init.d/php5-fpm reload
Tested the setup so far by creating a phpinfo file (updated the owner/group to www-data) & accesing it via "SERVER_IP/info.php"
Code: [Select]
nano /var/www/info.php
<?php
phpinfo();
?>
Installed tools/libraries required to build rtorrent
Code: [Select]
apt-get install subversion build-essential automake libtool libcppunit-dev libcurl3-dev libsigc++-2.0-dev unzip unrar-free curl libncurses-dev libxml2-dev
Created a directory for installation source
Code:
cd
mkdir install
cd install
Downloaded & compiled/installed latest xml-rpc (Q: Anything wrong with the parameters passed to the ./configure? I simply copied it over from other tutorials.)
Code:
svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc
cd xmlrpc
./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server --disable-cplusplus
make
make install
Downloaded & compiled/installed latest libtorrent
Code: [Select]
cd ../
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.3.tar.gz
tar xvf libtorrent-0.13.3.tar.gz
cd libtorrent-0.13.3
./autogen.sh
./configure --prefix=/usr
make
make install
Downloaded & compiled/installed latest rtorrent
Code:
cd ../
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.3.tar.gz
tar xvf rtorrent-0.9.3.tar.gz
cd rtorrent-0.9.3
./autogen.sh
./configure --prefix=/usr --with-xmlrpc-c
make
make install
ldconfig
Downloaded latest rutorrent
Code: [Select]
cd /var/www
svn checkout http://rutorrent.googlecode.com/svn/trunk/rutorrent
svn checkout http://rutorrent.googlecode.com/svn/trunk/plugins
rm -r rutorrent/plugins
mv plugins rutorrent/
Copied over the plugins.ini file contents from this tutorial
Created a new linux user to run rtorrent
Code:
useradd -d /home/torrentuser/ torrentuser
Created the required directories & config file under linux user "torrentuser"
Code:
mkdir /home/torrentuser
mkdir /home/torrentuser/downloads
mkdir /home/torrentuser/.session
mkdir /home/torrentuser/watch
mkdir /home/torrentuser/.sockets
touch /home/torrentuser/.sockets/rpc-socket
nano /home/torrentuser/.rtorrent.rc
Updated the owner for both /home/torrentuser & /var/www
Code:
chown -R torrentuser:torrentuser /home/torrentuser/
chown -R www-data:www-data /var/www
I've been trying to setup rutorrent with nginx. Since most of the tutorials I found are either with apache or are outdated nginx tutorials (no plugin rpc/httprpc), I've been struggling to get this work on my own (mainly due to my limited knowledge of linux).
My main aim is to reduce the memory usage as much as possible. So, instead of targeting some high end seedbox setup, I'm more inclined towards getting this work with low end VPS.
Any help would be appreciated in putting this whole as a proper working tutorial.
So far, I've done the following (currently tried this on Ubuntu 12.10):
Installed nginx via apt-get. (Q: Should we build/compile nginx on our own using "--without-http_scgi_module"? or it wouldn't make any difference if we later on use rutorrent plugin?)
Code:
apt-get install nginx
Installed PHP-FPM & PHP-CLI (I assume rutorrent require CLI)
Code:
apt-get install php5-fpm php5-cli
Edited nginx config to update the worker processes (equal to processor cores)
Code:
nano /etc/nginx/nginx.conf
[...]
worker_processes 1;
[...]
Created www directory in /var for website data
Code:
mkdir /var/www
Added a new website for rutorrent & enabled it by creating a symbolic link
Code:
nano /etc/nginx/sites-available/rutorrent
Code:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /var/www; ## Changed from : /usr/share/nginx/www
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
Code:
cd /etc/nginx/sites-enabled
ln -s ../sites-available/rutorrent
/etc/init.d/nginx reload
/etc/init.d/nginx restart
Edited PHP-FPM config to reduce the number of process & changed the spawning to ondemand (depending on the server specs, for low memory use?)
Code:
nano /etc/php5/fpm/pool.d/www.conf
[...]
pm = ondemand
pm.max_children = 2
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 2
pm.process_idle_timeout = 5s
[...]
/etc/init.d/php5-fpm reload
Tested the setup so far by creating a phpinfo file (updated the owner/group to www-data) & accesing it via "SERVER_IP/info.php"
Code: [Select]
nano /var/www/info.php
<?php
phpinfo();
?>
Installed tools/libraries required to build rtorrent
Code: [Select]
apt-get install subversion build-essential automake libtool libcppunit-dev libcurl3-dev libsigc++-2.0-dev unzip unrar-free curl libncurses-dev libxml2-dev
Created a directory for installation source
Code:
cd
mkdir install
cd install
Downloaded & compiled/installed latest xml-rpc (Q: Anything wrong with the parameters passed to the ./configure? I simply copied it over from other tutorials.)
Code:
svn checkout http://xmlrpc-c.svn.sourceforge.net/svnroot/xmlrpc-c/stable xmlrpc
cd xmlrpc
./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server --disable-cplusplus
make
make install
Downloaded & compiled/installed latest libtorrent
Code: [Select]
cd ../
wget http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.3.tar.gz
tar xvf libtorrent-0.13.3.tar.gz
cd libtorrent-0.13.3
./autogen.sh
./configure --prefix=/usr
make
make install
Downloaded & compiled/installed latest rtorrent
Code:
cd ../
wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.3.tar.gz
tar xvf rtorrent-0.9.3.tar.gz
cd rtorrent-0.9.3
./autogen.sh
./configure --prefix=/usr --with-xmlrpc-c
make
make install
ldconfig
Downloaded latest rutorrent
Code: [Select]
cd /var/www
svn checkout http://rutorrent.googlecode.com/svn/trunk/rutorrent
svn checkout http://rutorrent.googlecode.com/svn/trunk/plugins
rm -r rutorrent/plugins
mv plugins rutorrent/
Copied over the plugins.ini file contents from this tutorial
Created a new linux user to run rtorrent
Code:
useradd -d /home/torrentuser/ torrentuser
Created the required directories & config file under linux user "torrentuser"
Code:
mkdir /home/torrentuser
mkdir /home/torrentuser/downloads
mkdir /home/torrentuser/.session
mkdir /home/torrentuser/watch
mkdir /home/torrentuser/.sockets
touch /home/torrentuser/.sockets/rpc-socket
nano /home/torrentuser/.rtorrent.rc
Updated the owner for both /home/torrentuser & /var/www
Code:
chown -R torrentuser:torrentuser /home/torrentuser/
chown -R www-data:www-data /var/www