Friday, May 23, 2008

Installing Torrentflux-b4rt on Ubuntu/Debian

Torrentflux is an excellent torrent creation, downloading, and seeding program that is used in Linux, and is especially helpful in a multi-user environment, as it maintains separate directories for everyone with an account. That being said, let's get started! In order to have a working install of torrentflux, you need a LAMP (Linux, Apache, MySQL, PHP) installation (I should note that lighttpd will work in place of Apache, but for this guide, we're going to use Apache). Let's start with that. (NOTE: if any commands come back with permission problems, simply add sudo to the front of the command, e.g. sudo apt-get rather than just apt-get).

Before doing anything, you should do this:


apt-get update
apt-get upgrade



This will bring your install up to date on all of the installed components (chances are, any box you've gotten from a provider is not up to date, so this is a necessary step).

Now, installing a LAMP.


apt-get install apache2 php5 php5-mysql mysql-server php5-cgi



Now that we've installed a LAMP, we need to set up MySQL. First, we create the root password for MySQL.


MYSQL_PWD=putapasswordhere (I strongly suggest not using your machine's root password)



To verify the entry of the password, we type:


echo "Your password for the root account of MySQL will be : '$MYSQL_PWD'."



What's echoed should be what you put in above. Next, we tell MySQL what password to use.


mysqladmin -u root password "$MYSQL_PWD"



Now that we have that all taken care of, we need to create a database for torrentflux to use. We do this by naming the database:


MYSQL_DB=putadatabasenamehere (I normally just use torrentflux as my database name, but you can choose whatever you want)



and then creating it:


echo "CREATE DATABASE IF NOT EXISTS $MYSQL_DB DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci" \
| mysql --user=root --password



The password that it will ask for above will be the root password you defined in the first step of setting up MySQL.

Now, we need to actually create a user (and their subsequent password) to use the database. We do this by:


MYSQL_USERNAME=putausernamehere (up to you what to use, but remember what you put here)
MYSQL_USERPWD=putapasswordhere (again, I strongly suggest a different password than what's already in use)



To make sure the information you've put in is what you want, we'll ask the system to echo it back to us:


echo "The user account allowed to manage the '$MYSQL_DB' database is '$MYSQL_USERNAME' with password '$MYSQL_USERPWD'."



Now that we've created a user and password, we have to create that user in your new database.


echo "GRANT ALL PRIVILEGES ON $MYSQL_DB.*
TO $MYSQL_USERNAME@localhost
IDENTIFIED BY '$MYSQL_USERPWD';" | mysql --user=root --password



This will again prompt for that password we created when we first started setting up MySQL. Now, our work with MySQL is pretty much done. Now we move on to installing torrentflux itself.

First, we start off with installing its dependencies:


apt-get install bzip2 php5-gd php5-cli unrar-free grep python \
net-tools mawk wget unzip cksfv vlc-nox uudeview python-psyco python-crypto \
libxml-simple-perl libxml-dom-perl libdbd-mysql-perl libdigest-sha1-perl \
bittorrent bittornado



Once that's done, we can get to the nitty gritty install. First, we want to download torrentflux-b4rt:


cd /tmp/
wget http://download.berlios.de/tf-b4rt/torrentflux-b4rt_1.0-beta2.tar.bz2



Now, we need to extract it:


tar -xjf torrentflux-b4rt_1.0-beta2.tar.bz2 (alternatively, you can type torrent and press tab, and it should autocomplete the whole name of the file for you, assuming you don't have any other files in the /tmp/ directory with similar names



Now, we need to move torrentflux to its home:


mv torrentflux-b4rt_1.0-beta2 /opt/torrentflux



Now, we want to create a symbolic link from it's home to a place where the web front-end is visible and available to the HTTP server:


ln -s /opt/torrentflux/html /var/www/torrentflux



Now we need to make the configuration file writable by the webserver:


chown -R www-data:www-data /var/www/torrentflux/inc/config/



Now we need to create the download folder for torrentflux. Some things should be considered before doing this:

1. Are you going to be running an FTP server on this box as well? If so, you should make the torrentflux download directory the root of that FTP server
2. Are you going to be using glftpd as your FTP server? If so, I strongly suggest using /glftpd/site/ as your download directory.

That being said, let's assume you're not using any FTP server at all.


mkdir /var/lib/torrentflux



Now, we need to make it writable by the HTTP server:


chown -R www-data:www-data /var/lib/torrentflux



Most of the work through PuTTY is done. Now, we need to go about configuring it.

Before we do that, we want to restart apache to make sure it has everything loaded that it needs to.


/etc/init.d/apache2 restart



Once that's done, go to your web browser and type:


http://ipofyourbox/torrentflux/



This should forward you directly to setup.php and you can begin there. If it doesn't, simply add setup.php at the end of the above url.

For the most part, the web interface is self explanatory:

When prompted for what type of database you're going to use, use MySQL.
When prompted for the database information for your MySQL database, remember what you named the database, the user you created for it, and the password you created for that user.
[1*]Uncheck the box for "Create new database"
When asked what the Download location will be, use the directory you specified above (this guide has /var/lib/torrentflux as that directory)
On the software dependencies screen, you may have an error for unrar. That's ok, as we'll just adjust that after torrentflux is running. On Debian, VLC may show an error as well..this is ok, as you likely won't be using VLC.
At the completion of the configuration, it will tell you that it could not delete setup.php. This is normal. We'll be doing that manually.

Now, we remove setup.php.


rm /var/www/torrentflux/setup.php



Then, we make it so that the HTTP server can no longer right to the config folder:


chown -R root:root /var/www/torrentflux/inc/config/



We're just about done! Go back to your browser and type:


http://ipofyourbox/torrentflux



This should autoforward to login.php. If it doesn't, simply put login.php at the end of the url.

The first account you'll create is the superadmin account. This account is the only one that has all the features in it. I suggest using admin as the username, and a strong password for the password.

Once logged in, there are a lot of things to play around with, and ultimately, it's up to you to adjust as you see fit. The first page you'll want to look at is the server page, and adjust the unrar dependency. Simply add -free to the end of it, and you'll be fine with that.

Secondly, you'll want to look at the transfer page, where you'll want to adjust the max bandwidth for your connection (e.g. 12500 for a 100Mb connection). Alternatively, you could just put 0 and let it use the max available bandwidth. The rest of the settings are really up to you (I also strongly suggest using bittornado as yoru default torrent client).

That pretty much sums up this guide for installing torrentflux-b4rt.

Thanks to Lone Wolf

5 comments:

Anonymous said...

what's this mean?



wtf171:~# mysqladmin -u root password "$mysql_pwd"
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!

Edward said...

Thanks mate, worked like a charm. :D

-Edward

Unknown said...

How to use torrentflux user for FTP ?
I have a problem about it. please give me a solution.
Thanks and Regards

Anonymous said...

Thank you for this guide! I would just like to point out that I couldn't install cksfv with apt-get (repository issue?). Instead I found an url to an installfile and used wget to download cksfv.
Again, thank you. Great guide!
/Bactius

Anonymous said...

Despite a little hick-up with the sql server install, all is stil functional. Great work!