Note:
If you're running Apache 2.4.7 or newer, you might have /var/www/html as the Apache root dir. To read more, check this post and the reply I posted underneath.
Easy install script
You can now install the newest rTorrent + (optionally) ruTorrent with a shell script I made. It should work without any modifications on Debian and Ubuntu systems. Small modifications are needed to make it work on other systems.
To use the script, get the source code which you can find at http://pastebin.com/raw.php?i=0JYtEn2z and save it as "redtorrent.sh". Call it like this:
Code:
sudo sh redtorrent.sh <rtorrent-user>Replace <rtorrent-user> with the name of the user who will be running rTorrent (probably the user as which you're currently logged in).
There is a lot of customization possible with the script (such as disabling Apache installation and configuration which enables you to use the script with any web server) by simply changing some values under the Settings section at the beginning of the file. A few notes regarding these settings:
Things which I might add later
rTorrent is a really good torrent client but if you want it to work as good as possible, it requires some work to setup. This guide is more extensive as most other guides but the result will be worth it.
You will build libcurl/curl, xmlrpc-c, libtorrent and rtorrent yourself. This is the only way to install the latest version with support for asynchronous DNS, files pre-allocation and to have xmlrpc-c use the libxml2 library instead of an old version of Expat. If you didn't understand any of that, they are all things which will contribute to having an optimal rTorrent + ruTorrent setup. Before starting, you might want to read the list of notes under the "Easy install script" section. Even if you're not going to use the script, it's useful information.
Note: this guide doesn't contain any specific instructions for web servers different from Apache so the ruTorrent part might be slightly different if you're using nginx/lighttpd/whatever.
Make sure you're logged in as a normal user (non-root) and only run commands as root ("sudo" or "su") when I use "sudo" (and of course, when installing packages).
If you're using a Debian or Ubuntu system, you will need to install the following packages to build everything:
build-essential automake pkg-config libcppunit-dev libtool
If you're going to use a web interface for rTorrent (e.g.: ruTorrent), you will also need to install a web server and PHP5. On Debian and Ubuntu, install Apache + PHP5 with the following package:
libapache2-mod-php5
I also recommend you to install the PHP5 command-line interpreter. It's not strictly necessary but you'll probably want to have that functionality at some point anyway (some ruTorrent plugins need it).
php5-cli
Checkinstall
Checkinstall is an installation tracker which creates and installs packages (Debian/Ubuntu, Slackware or RPM). This allows you to install self-built software as packages which can be managed by your favorite package manager (e.g.: aptitude). This is not needed to setup rTorrent + ruTorrent, skip this section if you're not interested.
If you've installed checkinstall, I recommend you to disable file-system translation by changing the config file. This is to avoid unexpected errors later. Open /etc/checkinstallrc in a text-editor, search for the line where it says TRANSLATE and set it to 0.
Code:
TRANSLATE=0
To use, run "checkinstall make install" where you'd normally just type "make install". See the manual for more info.
Configure Apache
If you installed Apache, add the following line to your configuration file. Usually this is "httpd.conf" although it's called "apache2.conf" on some distro's (e.g. Debian and Ubuntu). This file is located in your Apache root directory (usually /etc/apache2/). You can also create a new config file (of which you can choose the name) and place it in /etc/apache2/conf.d/, this will have the same effect.
Code:
ServerName localhost
Create temp dir
Code:
mkdir ~/install
cd ~/install
Install libcurl + curl
Compiling this yourself will allow you to add support for asynchronous DNS which will result in a more responsive rTorrent.
First you'll need to install the development files of OpenSSL, c-ares, libssh2 and Libidn. On Debian and Ubuntu you can do this by installing the following packages: libssl-dev libc-ares-dev libssh2-1-dev libidn11-dev
Why? First one is for SSL support, second one for Asynchronous DNS support, third one for SSH (SCP + SFTP) support and the last one is for International Domain Names (IDN) support. The SSH and the IDN support is not needed for rTorrent + ruTorrent so you can skip them if you want.
Now download, build and install libcurl + curl. If you chose not to install some of the packages listed above, don't forget to remove the arguments to include them in the build ("--with-libssh2" for SSH and "--with-libidn" for IDN).
Code:
wget http://curl.haxx.se/download/curl-7.37.0.tar.gz
tar xzf curl-7.37.0.tar.gz
cd curl-7.37.0
./buildconf
./configure --enable-ares --enable-tls-srp --with-zlib --with-ssl --with-libssh2 --with-libidn
make
sudo make install
sudo ldconfig
cd ..
NOTE: if you used checkinstall, you might have encountered a warning message similar to the following one:
Quote
Cause is that checkinstall fails to auto detect the correct version number. You can just input the version of curl which you're installing (this is 7.37.0 if you used the commands above).
Install xmlrpc-c
You will need to install subversion to download this one. Most distro's have a subversion package which you can install.
You'll also need the development files of libxml2 to build this which can be obtained on Debian and Ubuntu systems by installing the libxml2-devpackage.
By default, xmlrpc-c will use an old version of Expat for XML parsing. Now that you have libxml2, you can instruct xmlrpc-c to use this instead.
Code: [Select]
svn checkout https://svn.code.sf.net/p/xmlrpc-c/code/stable/ xmlrpc-c
cd xmlrpc-c
./configure --enable-libxml2-backend --disable-abyss-server --disable-cgi-server
make
sudo make install
cd ..
Optionally, you can also install xmlrpc-c tools (XML-RPC client program). If you don't know what this is or you don't think you need this, skip this.
Code:
cd xmlrpc-c/tools
make
sudo make install
cd ..
Install libTorrent
If, for some reason, you aren't going to install the newest rTorrent (version 0.9.3 or earlier), you'll also need to install libsigc++ which can be installed on Debian and Ubuntu by installing the libsigc++-2.0-dev package.
Currently, the newest libTorrent is 0.13.4. Compiling this yourself allows you to install the newest version and to add support for pre-allocation of files (which still needs to be enabled in the config file if you want to use it).
Code:
curl -O http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.4.tar.gz
tar xzf libtorrent-0.13.4.tar.gz
cd libtorrent-0.13.4
./autogen.sh
./configure --with-posix-fallocate
make
sudo make install
cd ..
Install rTorrent
Install ncurses first. This can be done on Debian and Ubuntu systems by installing the libncurses5-dev package. Now download, build and install the BitTorrent client.
Code:
curl -O http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.4.tar.gz
tar xzf rtorrent-0.9.4.tar.gz
cd rtorrent-0.9.4
./autogen.sh
./configure --with-xmlrpc-c
make
sudo make install
sudo ldconfig
cd ..
Configure rTorrent
rTorrent can be configured easily by placing a config file named ".rtorrent.rc" in your home dir. An example of such a file can be found here http://pastebin.com/raw.php?i=YEpTJjR6. Tweak the file to your needs (do NOT skip this part) and make sure it contains the following:
Code: [Select]
scgi_port = 127.0.0.1:5000The old syntax for this is network.scgi.open_port = 127.0.0.1:5000. Use the syntax above instead.
Install ruTorrent
Download ruTorrent and move the folder to your web-server root.
Code: [Select]
curl -LO http://dl.bintray.com/novik65/generic/rutorrent-3.6.tar.gz
tar xzf rutorrent-3.6.tar.gz
sudo mv rutorrent /var/www
cd ..
Optionally, you can also download the official plugins (highly recommended) and move them to your ruTorrent folder. Some plugins also have some dependencies which need to be installed first, these are (as far as I know):
Done? Now download and install the plugins.
Code: [Select]
curl -LO http://dl.bintray.com/novik65/generic/plugins-3.6.tar.gz
tar xzf plugins-3.6.tar.gz
sudo mv plugins /var/www/rutorrent
cd ..
For ruTorrent to function properly, the web server user needs read, write and execute permissions on the ruTorrent folder. Take ownership of the ruTorrent directory and change permissions with the following commands:
Code: [Select]
sudo chown -R <rtorrent-user>:<web-server-group> /var/www/rutorrent
sudo chmod -R 770 /var/www/rutorrentIf you're unsure as what to fill in as <rutorrent-user>, just use your current username. If you don't know what to use as <web-server-group>, it's probably "www-data" so fill that in.
rTorrent - ruTorrent communication
ruTorrent communicates with rTorrent using RPC. You can choose to do this either over SCGI or over HTTP.
XML-RPC over SCGI is the default setup. This is the best solution for embedded systems where you need to keep the CPU load as low as possible. To setup rTorrent + ruTorrent using XML-RPC over SCGI, skip to "XML-RPC over SCGI".
RPC over HTTP is a simpler and more secure setup. There are two ruTorrent plugins which implement RPC over HTTP (obviously, you have to have the official plugins installed to be able to use one of them).
Choose ONE and do not use either in combination with XML-RPC over SCGI (it will work but it defeats the purpose).
XML-RPC over SCGI
If you installed Apache, you will need to install the SCGI mod. On Debian and Ubuntu, you do this by installing the libapache2-mod-scgi package.
Now add this to your Apache config file
Code: [Select]
SCGIMount /RPC2 127.0.0.1:5000
And enable the SCGI module
Code: [Select]
sudo a2enmod scgi
Finally, add the following to your ruTorrent plugins.ini file (/var/www/rutorrent/conf/plugins.ini) to disable the RPC and HTTPRPC plugins.
Code: [Select]
[httprpc]
enabled = no
[rpc]
enabled = no
XML-RPC with the RPC plugin
Add the following to your ruTorrent plugins.ini file (/var/www/rutorrent/conf/plugins.ini) to enable the RPC plugin and disable the HTTPRPC plugin.
Code: [Select]
[rpc]
enabled = yes
[httprpc]
enabled = no
JSON-RPC with the HTTPRPC plugin
Add the following to your ruTorrent plugins.ini file (/var/www/rutorrent/conf/plugins.ini) to enable the HTTPRPC plugin and disable the RPC plugin.
Code: [Select]
[httprpc]
enabled = yes
[rpc]
enabled = no
Final step - restart the web-server
For Apache, type the following:
Code: [Select]
sudo service apache2 restart
Using rTorrent with screen
Screen is a terminal multiplexer. Or simply said, a utility to run multiple sessions at the same time. That way you can start rTorrent as a detached session and use terminal for other things while rTorrent keeps running in the background. Here is a small list of commands to use when using rTorrent with screen.
Start rTorrent detached
screen -S rtorrent -d -m rtorrent
Resume detached session
screen -S rtorrent -r
Quit detached rTorrent session
screen -S rtorrent -X xon
Detach current session from this terminal
Ctrl+a d
Quit current rTorrent session
Ctrl+a q
Using rTorrent with tmux
tmux is another terminal multiplexer (so you don't need this if you just installed screen). Use the following list of commands to control rTorrent with tmux.
Start rTorrent detached
tmux new-session -s bittorrent -n rtorrent -d rtorrent
Resume detached session
tmux attach -t bittorrent
Quit detached rTorrent session
tmux send-keys -t bittorrent:rtorrent C-q
Detach current session from this terminal
Ctrl+b d
Quit current rTorrent session
Ctrl+q
If you have questions or suggestions...
...please do leave a comment
If you're running Apache 2.4.7 or newer, you might have /var/www/html as the Apache root dir. To read more, check this post and the reply I posted underneath.
Easy install script
You can now install the newest rTorrent + (optionally) ruTorrent with a shell script I made. It should work without any modifications on Debian and Ubuntu systems. Small modifications are needed to make it work on other systems.
To use the script, get the source code which you can find at http://pastebin.com/raw.php?i=0JYtEn2z and save it as "redtorrent.sh". Call it like this:
Code:
sudo sh redtorrent.sh <rtorrent-user>Replace <rtorrent-user> with the name of the user who will be running rTorrent (probably the user as which you're currently logged in).
There is a lot of customization possible with the script (such as disabling Apache installation and configuration which enables you to use the script with any web server) by simply changing some values under the Settings section at the beginning of the file. A few notes regarding these settings:
- If you're going to install rTorrent on a system with low resources (e.g.: Raspberry Pi or embedded systems), it would be best to install version 0.9.3. Therefore, change RTVERSION="0.9.4" to RTVERSION="0.9.3".
- If you really wish to keep the CPU load as low as possible, you'll also want the communication between rTorrent and ruTorrent to go over SCGI. To have it setup this way, change RUTORRENT_RPC="HTTPRPC" to RUTORRENT_RPC="SCGI".
Note: I recommend you to not change this one unless you need it! - By default, rTorrent will be built with atomic operations (only applicable if you didn't change RTVERSION). This means GCC version 4.7 or higher is required. If building rTorrent fails, this is most likely the cause. To build rTorrent without atomic operations, change ATOMIC="1" to ATOMIC="0". Other solutions are to update GCC or alternatively, to install the previous version of rTorrent instead (see my first point).
- By default, self-built software will be installed as packages ("curl", "xmlrpc-c", "libtorrent" and "rtorrent") using a tool named "Checkinstall". If you experience problems with this or if you wish to disable this behavior for some other reason, change CHECKINSTALL="1" to CHECKINSTALL="0".
- Read the comments in the settings section!
Things which I might add later
- Init script
- Config-fu
- Server security
rTorrent is a really good torrent client but if you want it to work as good as possible, it requires some work to setup. This guide is more extensive as most other guides but the result will be worth it.
You will build libcurl/curl, xmlrpc-c, libtorrent and rtorrent yourself. This is the only way to install the latest version with support for asynchronous DNS, files pre-allocation and to have xmlrpc-c use the libxml2 library instead of an old version of Expat. If you didn't understand any of that, they are all things which will contribute to having an optimal rTorrent + ruTorrent setup. Before starting, you might want to read the list of notes under the "Easy install script" section. Even if you're not going to use the script, it's useful information.
Note: this guide doesn't contain any specific instructions for web servers different from Apache so the ruTorrent part might be slightly different if you're using nginx/lighttpd/whatever.
Make sure you're logged in as a normal user (non-root) and only run commands as root ("sudo" or "su") when I use "sudo" (and of course, when installing packages).
If you're using a Debian or Ubuntu system, you will need to install the following packages to build everything:
build-essential automake pkg-config libcppunit-dev libtool
If you're going to use a web interface for rTorrent (e.g.: ruTorrent), you will also need to install a web server and PHP5. On Debian and Ubuntu, install Apache + PHP5 with the following package:
libapache2-mod-php5
I also recommend you to install the PHP5 command-line interpreter. It's not strictly necessary but you'll probably want to have that functionality at some point anyway (some ruTorrent plugins need it).
php5-cli
Checkinstall
Checkinstall is an installation tracker which creates and installs packages (Debian/Ubuntu, Slackware or RPM). This allows you to install self-built software as packages which can be managed by your favorite package manager (e.g.: aptitude). This is not needed to setup rTorrent + ruTorrent, skip this section if you're not interested.
If you've installed checkinstall, I recommend you to disable file-system translation by changing the config file. This is to avoid unexpected errors later. Open /etc/checkinstallrc in a text-editor, search for the line where it says TRANSLATE and set it to 0.
Code:
TRANSLATE=0
To use, run "checkinstall make install" where you'd normally just type "make install". See the manual for more info.
Configure Apache
If you installed Apache, add the following line to your configuration file. Usually this is "httpd.conf" although it's called "apache2.conf" on some distro's (e.g. Debian and Ubuntu). This file is located in your Apache root directory (usually /etc/apache2/). You can also create a new config file (of which you can choose the name) and place it in /etc/apache2/conf.d/, this will have the same effect.
Code:
ServerName localhost
Create temp dir
Code:
mkdir ~/install
cd ~/install
Install libcurl + curl
Compiling this yourself will allow you to add support for asynchronous DNS which will result in a more responsive rTorrent.
First you'll need to install the development files of OpenSSL, c-ares, libssh2 and Libidn. On Debian and Ubuntu you can do this by installing the following packages: libssl-dev libc-ares-dev libssh2-1-dev libidn11-dev
Why? First one is for SSL support, second one for Asynchronous DNS support, third one for SSH (SCP + SFTP) support and the last one is for International Domain Names (IDN) support. The SSH and the IDN support is not needed for rTorrent + ruTorrent so you can skip them if you want.
Now download, build and install libcurl + curl. If you chose not to install some of the packages listed above, don't forget to remove the arguments to include them in the build ("--with-libssh2" for SSH and "--with-libidn" for IDN).
Code:
wget http://curl.haxx.se/download/curl-7.37.0.tar.gz
tar xzf curl-7.37.0.tar.gz
cd curl-7.37.0
./buildconf
./configure --enable-ares --enable-tls-srp --with-zlib --with-ssl --with-libssh2 --with-libidn
make
sudo make install
sudo ldconfig
cd ..
NOTE: if you used checkinstall, you might have encountered a warning message similar to the following one:
Quote
Warning "..." is not a Debian policy compliant one. Please specify an alternate one.
Cause is that checkinstall fails to auto detect the correct version number. You can just input the version of curl which you're installing (this is 7.37.0 if you used the commands above).
Install xmlrpc-c
You will need to install subversion to download this one. Most distro's have a subversion package which you can install.
You'll also need the development files of libxml2 to build this which can be obtained on Debian and Ubuntu systems by installing the libxml2-devpackage.
By default, xmlrpc-c will use an old version of Expat for XML parsing. Now that you have libxml2, you can instruct xmlrpc-c to use this instead.
Code: [Select]
svn checkout https://svn.code.sf.net/p/xmlrpc-c/code/stable/ xmlrpc-c
cd xmlrpc-c
./configure --enable-libxml2-backend --disable-abyss-server --disable-cgi-server
make
sudo make install
cd ..
Optionally, you can also install xmlrpc-c tools (XML-RPC client program). If you don't know what this is or you don't think you need this, skip this.
Code:
cd xmlrpc-c/tools
make
sudo make install
cd ..
Install libTorrent
If, for some reason, you aren't going to install the newest rTorrent (version 0.9.3 or earlier), you'll also need to install libsigc++ which can be installed on Debian and Ubuntu by installing the libsigc++-2.0-dev package.
Currently, the newest libTorrent is 0.13.4. Compiling this yourself allows you to install the newest version and to add support for pre-allocation of files (which still needs to be enabled in the config file if you want to use it).
Code:
curl -O http://libtorrent.rakshasa.no/downloads/libtorrent-0.13.4.tar.gz
tar xzf libtorrent-0.13.4.tar.gz
cd libtorrent-0.13.4
./autogen.sh
./configure --with-posix-fallocate
make
sudo make install
cd ..
Install rTorrent
Install ncurses first. This can be done on Debian and Ubuntu systems by installing the libncurses5-dev package. Now download, build and install the BitTorrent client.
Code:
curl -O http://libtorrent.rakshasa.no/downloads/rtorrent-0.9.4.tar.gz
tar xzf rtorrent-0.9.4.tar.gz
cd rtorrent-0.9.4
./autogen.sh
./configure --with-xmlrpc-c
make
sudo make install
sudo ldconfig
cd ..
Configure rTorrent
rTorrent can be configured easily by placing a config file named ".rtorrent.rc" in your home dir. An example of such a file can be found here http://pastebin.com/raw.php?i=YEpTJjR6. Tweak the file to your needs (do NOT skip this part) and make sure it contains the following:
Code: [Select]
scgi_port = 127.0.0.1:5000The old syntax for this is network.scgi.open_port = 127.0.0.1:5000. Use the syntax above instead.
Install ruTorrent
Download ruTorrent and move the folder to your web-server root.
Code: [Select]
curl -LO http://dl.bintray.com/novik65/generic/rutorrent-3.6.tar.gz
tar xzf rutorrent-3.6.tar.gz
sudo mv rutorrent /var/www
cd ..
Optionally, you can also download the official plugins (highly recommended) and move them to your ruTorrent folder. Some plugins also have some dependencies which need to be installed first, these are (as far as I know):
- autotools: php5-cli
- rss: php5-cli
- unpack: unzip and unrar-free
- screenshots: ffmpeg
- mediainfo: mediainfo
Done? Now download and install the plugins.
Code: [Select]
curl -LO http://dl.bintray.com/novik65/generic/plugins-3.6.tar.gz
tar xzf plugins-3.6.tar.gz
sudo mv plugins /var/www/rutorrent
cd ..
For ruTorrent to function properly, the web server user needs read, write and execute permissions on the ruTorrent folder. Take ownership of the ruTorrent directory and change permissions with the following commands:
Code: [Select]
sudo chown -R <rtorrent-user>:<web-server-group> /var/www/rutorrent
sudo chmod -R 770 /var/www/rutorrentIf you're unsure as what to fill in as <rutorrent-user>, just use your current username. If you don't know what to use as <web-server-group>, it's probably "www-data" so fill that in.
rTorrent - ruTorrent communication
ruTorrent communicates with rTorrent using RPC. You can choose to do this either over SCGI or over HTTP.
XML-RPC over SCGI is the default setup. This is the best solution for embedded systems where you need to keep the CPU load as low as possible. To setup rTorrent + ruTorrent using XML-RPC over SCGI, skip to "XML-RPC over SCGI".
RPC over HTTP is a simpler and more secure setup. There are two ruTorrent plugins which implement RPC over HTTP (obviously, you have to have the official plugins installed to be able to use one of them).
Choose ONE and do not use either in combination with XML-RPC over SCGI (it will work but it defeats the purpose).
- RPC: XML-RPC over HTTP. Simple but useful. Skip to "XML-RPC with the RPC plugin" for instructions.
- HTTPRPC (recommended): JSON-RPC over HTTP. Decreases bandwidth usage a lot. Skip to "JSON-RPC with the HTTPRPC plugin" for instructions.
XML-RPC over SCGI
If you installed Apache, you will need to install the SCGI mod. On Debian and Ubuntu, you do this by installing the libapache2-mod-scgi package.
Now add this to your Apache config file
Code: [Select]
SCGIMount /RPC2 127.0.0.1:5000
And enable the SCGI module
Code: [Select]
sudo a2enmod scgi
Finally, add the following to your ruTorrent plugins.ini file (/var/www/rutorrent/conf/plugins.ini) to disable the RPC and HTTPRPC plugins.
Code: [Select]
[httprpc]
enabled = no
[rpc]
enabled = no
XML-RPC with the RPC plugin
Add the following to your ruTorrent plugins.ini file (/var/www/rutorrent/conf/plugins.ini) to enable the RPC plugin and disable the HTTPRPC plugin.
Code: [Select]
[rpc]
enabled = yes
[httprpc]
enabled = no
JSON-RPC with the HTTPRPC plugin
Add the following to your ruTorrent plugins.ini file (/var/www/rutorrent/conf/plugins.ini) to enable the HTTPRPC plugin and disable the RPC plugin.
Code: [Select]
[httprpc]
enabled = yes
[rpc]
enabled = no
Final step - restart the web-server
For Apache, type the following:
Code: [Select]
sudo service apache2 restart
Using rTorrent with screen
Screen is a terminal multiplexer. Or simply said, a utility to run multiple sessions at the same time. That way you can start rTorrent as a detached session and use terminal for other things while rTorrent keeps running in the background. Here is a small list of commands to use when using rTorrent with screen.
Start rTorrent detached
screen -S rtorrent -d -m rtorrent
Resume detached session
screen -S rtorrent -r
Quit detached rTorrent session
screen -S rtorrent -X xon
Detach current session from this terminal
Ctrl+a d
Quit current rTorrent session
Ctrl+a q
Using rTorrent with tmux
tmux is another terminal multiplexer (so you don't need this if you just installed screen). Use the following list of commands to control rTorrent with tmux.
Start rTorrent detached
tmux new-session -s bittorrent -n rtorrent -d rtorrent
Resume detached session
tmux attach -t bittorrent
Quit detached rTorrent session
tmux send-keys -t bittorrent:rtorrent C-q
Detach current session from this terminal
Ctrl+b d
Quit current rTorrent session
Ctrl+q
If you have questions or suggestions...
...please do leave a comment