Install/Setup Seedbox on VPS or Dedicated server running Centos OS

What is this tutorial for?
In this tutorial I will show you how to setup your seedbox on a Dedicated Server (or VPS) running on CentOS 6. It's a step-by-step guide rather than an auto-install script so you will be able to install the latest version of the softwares.
Centos OS
Other stuffs
If there happen to be enough interest, I will add to this tutorial:
1. Disabling root SSH login access for additional security & enable sudo for other users.
2. Add Basic Authentication (username/password prompt) to the ruTorrent Web GUI.
3. Deluge installation.
4. Disable all IP logging on the server for total anonimity.
5. Install Squid proxy server and use it on your browser for anonymous surfing.

Prerequisites
1. SSH Client: you can get PuTTY from PuTTY Download Page
2. Dedicated Server SSH Root Login data.

Getting Started
First of all, we are going to change the SSH port for security reasons. Login to your server with PuTTY as root and open the SSH configuration file.

 

nano /etc/ssh/sshd_config

Using nano, you can search text hitting CTRL+W. Edit the file reflecting these changes:

 

Port <portNo>

Protocol 2

X11Forwarding no

Replace <portNo> with a random port in the 40000 – 65535 range.
NOTE: If you want higher security you should also disable root login (PermitRootLogin no) but before doing that make sure you have created a new user and added it to the sudoers list. This is beyond the purpose of this tutorial.

Now you have to restart the SSH server daemon.

 

/etc/init.d/ssh reload

Now we have to create a new user which will run the torrent client daemons. Replace <username> with the username you want to use, of course.

Issue the useradd command to create a locked user account:

 

useradd <username>

Unlock the account by issuing the passwd command to assign a password:

 

passwd <username>

Web Server (nginx) + PHP installation
We’ll need to grab some extra repositories first.

 

wget http://fedora.mirror.nexicom.net/epel/6/i386/epel-release-6-8.noarch.rpm

rpm -Uvh epel-release-6-8.noarch.rpm

Nginx offers their own repository of pre-built packages for CentOS 6. We can grab those by running these commands: 

 

wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

rpm -Uvh nginx-release-centos-6-0.el6.ngx.noarch.rpm

Lastly, we need to grab the REMI repository which provides the php-fpm package. This can be easily done by the following: 

 

rpm –import http://rpms.famillecollet.com/RPM-GPG-KEY-remi

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

Nginx 1.2.6

Then we install nginx!

 

yum -y install nginx

chkconfig –levels 235 nginx on

/etc/init.d/nginx start

If you’ve done everything right up to this point, you should be able to get to the default nginx page in your browser!

PHP 5.4.11

Installing PHP is quite simple. Since this is going to be a seedbox, we only need a small handful of PHP modules. We’ll also be installing APC to help speed PHP processing up, which can be handy for large torrent operations.

 

yum -y install php-fpm php-cli php-mysql php-gd php-odbc php-pear  php-xml php-xmlrpc php-magickwand php-mbstring php-mcrypt php-shout  php-snmp php-soap php-tidy

yum -y install php-pecl-apc

With all that installed, we’ll go ahead and update the necessary items in the /etc/php.ini file. First we want to set cgi.fix_pathinfo to 0, then set the proper timezone.

 

[Date]

; Defines the default timezone used by the date functions

; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone

date.timezone = “America/Vancouver”

 

 

 

; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's

; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok

; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting

; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting

; of zero causes PHP to behave as before. Default is 1. You should fix your scripts

; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.

; http://www.php.net/manual/en/ini.core.php#ini.cgi.fix-pathinfo

cgi.fix_pathinfo=0

Finally, we want to add PHP to the startup configuration and start the service itself.

 

chkconfig –levels 235 php-fpm on

/etc/init.d/php-fpm start

Before we can test PHP support, we need to actually configure nginx to make use of our php-fpm service. We’ll also do a bit of basic tuning to juice a wee bit more performance from nginx.

Edit the main nginx configuration, found in /etc/nginx/nginx.conf.

 

 

worker_processes  4;

 

    keepalive_timeout  2;

 

Now we’ll setup our default virtual host. The vhosts are managed via a separate file (/etc/nginx/conf.d/default.conf)

 

 

server_name localhost;

 

location / {

 root /usr/share/nginx/html;

 index index.php index.html index.htm;

 }

 

    location ~ \.php$ {

        root           /usr/share/nginx/html;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include        fastcgi_params;

    }

Keep a close eye on the root and fastcgi_param variables, as with those being wrong, PHP won’t work.

rTorrent + ruTorrent installation
We’ll need to build these suckers from source, partially to get the XMLRPC support in and partially because the version in the repos is quite out of date.

 

mkdir ~/torrent

cd ~/torrent

wget http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.2.tar.gz  http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.2.tar.gz

For the next step, I take the ‘throw every ******* package at it cause I’m too lazy to do it any other way’ approach. By this, I mean using the ‘groupinstall’ feature of yum.

 

yum -y groupinstall “Development tools” “Server Platform   Development” && yum -y install cppunit-devel   libsigc++20-devel.i686 libsigc++20-devel.x86_64 libcurl-devel   xmlrpc-c-devel.i686 xmlrpc-c-devel.x86_64

Now we can begin building libtorrent and rtorrent.

 

tar xzf libtorrent-*.tar.gz

cd libtorrent-0.13.2

./autogen.sh

./configure; make; make install

ldconfig


With libtorrent configured and built, we can proceed to configuring/building rtorrent. Notice that we’re configuring rtorrent with the –with-xmlrpc-c flags. This is so we get the XMLRPC support which is required for any type of WebGUI.

 

cd ../

tar xzf rtorrent-*.tar.gz

cd rtorrent-0.9.2

./configure –with-xmlrpc-c

make

make install

With all that done, we should have a functional copy of rTorrent built.
We’ll want to run rtorrent as another user, but we don’t want to allow SSH logins as that user, since that will create a giant security hole. Before we get to that though, we need to download the stock rtorrent.rc file to the home directory of the user we created before. I assume we used sbox.

If you don't know where the home directory of the user is located:

 

grep sbox /etc/passwd

sbox:x:500:500::/home/sbox:/bin/bash

 

cd /home/sbox

wget http://libtorrent.rakshasa.no/export/1303/trunk/rtorrent/doc/rtorrent.rc

mv rtorrent.rc .rtorrent.rc

We rename it to .rtorrent.rc, as that’s what rtorrent looks for on startup. Open the .rtorrent.rc configuration file and add/edit/uncomment the following lines:

 

#SCGI Port

scgi_port = localhost:5000

 

# Default directory to save the downloaded torrents.

directory = /home/sbox/torrents/downloads/

# Default session directory.

session = /home/sbox/torrents/session/

Now we have to create the directories used by rtorrent.

 

mkdir -p /home/sbox/torrents/downloads/

mkdir -p /home/sbox//torrents/session/

chown -R sbox:sbox /home/sbox/torrents


Lastly we have to update our nginx configuration to add the proper SCGI mounts.

 

nano /etc/nginx/conf.d/default.conf

 

location /RPC2 {

include scgi_params;

scgi_pass localhost:5000

}

Change to your public HTML directory and download rutorrent and the plugins package:

 

cd /usr/share/nginx/html/

wget http://rutorrent.googlecode.com/files/plugins-3.5.tar.gz http://rutorrent.googlecode.com/files/rutorrent-3.5.tar.gz

tar xzf rutorrent-3.5.tar.gz

tar xzf plugins-3.5.tar.gz

cp -a plugins/* rutorrent/plugins/

rm -rf plugins*

Last but not least, we have to start rtorrent in a screen session (or some other detachable shell software):

 

screen #this will open a new screen seesion

su sbox -c rtorrent -s /bin/sh

To detach from the screen session without closing rtorrent daemon, you can just hit CTRL+A then ‘d'.

Now you should be able to access http://yourserver/rutorrent and get the rutorrent page. You may get a couple of errors about missing programs for some plugins, but all should work just fine.

-By Alienbuddy

0/5 (0 Reviews)

Promoting Torrent privacy since 2012

Company