How-to: Installing Torrent-Flux

Important Note:
This how-to was written for Ubuntu 6.06 (Dapper Drake), for manually installing torrentflux.

However, torrentflux has since been added to the repositories. Thus, installation should now be much simpler. You can just go to the Synaptic package manager (Applications > Add/Remove) and install it. (Use Adept on Kubuntu.) On the commandline, you can go:

Code:

sudo aptitude install torrentflux

That replaces steps 3 and 4a from the guide. The rest of the guide details other aspects of getting torrentflux installed and working. You can also use the entire guide (including steps 3 and 4a) if you want to do a manual install for some reason.

I've had several friends ask about how to get torrentflux working, so I'm posting this how-to to in case anyone else finds it useful.

Introduction
Torrentflux is a neat open-source bit-torrent application. The interesting thing about it is that it runs entirely as a web-application. This means that you can access it remotely, from anywhere, using a web-browser. You can initiate, monitor, and manage your bit-torrent downloads while away from your computer.

The only 'catch' is that you need to be running a full webserver (including PHP and MySQL) for this to work. Luckily it's rather simple to get this working in Linux. If you're running Ubuntu, you should have no problem getting this to work.

It may seem like 'overkill' to install a whole LAMP environment just for torrentflux, however you may soon discover that there are many neat things you can do with a functional LAMP stack. Torrent-flux is only one example.

Step 1: Get a functional LAMP stack.

To get a 'LAMP' stack running (Linux Apache Mysql Php), you just install the packages "apache2", "php5" and "mysql-server". You can do this using Synaptic (Ubuntu) or Adept (Kubuntu), or on the command line:

Once these are installed, you should be able to test it by pointing your web-browser to:http://localhost/

You should see a web-page, not an error message. (You may see a simple web-dir listing with "apache2-default" in it... that's normal.) To test if PHP is working properly, just create a simple test page. For instance, create a file:

Since your PHP/MySQL interface will eventually be world-accessible, it makes sense to put some security in place. By default MySQL starts with no password, so you should certainly set one:

Code:

$ mysqladmin -uroot password 'new-password'

(Note: if you're ever having trouble coming up with good passwords, install and run a simple commandline program called "pwgen" ... it will suggest strong passwords that are reasonably easy to remember.)

Step 2: Make sure you can access your webserver.

A common stumbling block in getting a LAMP stack fully functional is that port 80 is blocked. This may be because the Internet Service Provider (ISP) is blocking it, or because your router's firewall is blocking it. To test whether or not you are blocked, first find out your world-facing ("external") IP address. You can do this in any number of ways, such as visiting sites like:http://www.ipaddressworld.com/

(Where the x's are your IP address, of course.) If you see the same apache page in both cases, then everything is working. If in the second case you get an erorrt, then somewhere along the line port 80 is being blocked. It could be your ISP, or the firewall in your router (if any).

2.a Opening up port 80 on a router.

If you have a router, you should log into it and open up port 80. First find out your local IP address (the one inside your local network). To do this just type:

Code:

$ ifconfig

Among other things, you should see something like "inet addr:192.168.1.101" (usually in the first block of output, marked "eth0"). That is your internal IP address.

Then access your router's administration mode. Typically you access your router by using a web-browser and going to "http://192.168.1.1/" or "http://192.168.15.1/" or some other "special address" like that. You will need to find the documentation for your specific router. You will probably also have to enter a username and password to get access to the router admin page.

Once there, you will need to find a section marked "Application & Gaming" or "Port Forwarding" or something similar. In this section, you should set up a new rule along the lines of:

Needless to say, you should replace the "192.168.1.101" in the above example with the internal IP address you determined previously. You may need to restart the router for changes to take effect (simply unplugging it for a few seconds should work).

2.b Using a non-standard port.
If the above did not work, then it is likely that port 80 is being blocked by your ISP. Many residential ISPs will block port 80 (the standard port for http web requests), so you may need to use a non-standard port. Doing so is relatively simple, however. First edit the configuration for your webserver:

Code:

$ sudo nano /etc/apache2/apache2.conf

And add a line that says:

Code:

Listen 8080

The "8080" is the non-standard port we will use. You can pick any port you want, as long as it is greater than 1024 (low ports are reserved and probably also blocked). You need to restart apache for hte change to take effect:

Code:

$ sudo /etc/init.d/apache2 restart

Then modify your router to allow port 8080 to be forwarded to your computer. Use the guidelines given above (section 2.a), except put "8080" instead of "80".

In both cases you should get to your apache page, like before. If this doesn't work then go back over the steps and double-check what you've done. It may also be that your router doesn't support port-forwarding properly. In some cases you can "flash the firmware" on your router to fix the problem.

Instead of user:user you should put your username and group. (They are usually the same, and are simply the name you login with.) The above "cd" command will vary depending on where you untared the files.

4.b MySQL.
We also need MySQL setup properly. Create a database for torrentflux:

Code:

$ mysqladmin -uroot -p create torrentflux

(You'll need to enter the MySQL password you set previously.) Now go into the "sql" sub-directory in torrentflux (depends on where you untared torrentflux, of course):

Code:

$ cd ~/Desktop/torrentflux_2.1/sql

And upload the torrentflux structure to MySQL:

Code:

$ mysql -uroot -p torrentflux < mysql_torrentflux.sql

If you don't like using MySQL on the commandline, you can install a program called "phpmyadmin" that gives you easy web-browser access to all of the functionality in MySQL. Once installed, you access it by pointing your web-browser to: http://localhost/phpmyadmin/

Now you need to tell torrentflux the password you set for your MySQL system. So you edit the file:

You can modify the "db_pass" line with the password you selected before.

4.c New MySQL User
For added security/control, you may prefer to give torrentflux a "non-root" MySQL access. This can be important if you have lots of different applications all using MySQL. To do this, you can use "phpmyadmin" or enter these commands one at a time:

On your first login you the username and password you supply will be the "administrator account" for torrentflux. Make sure you rememeber the password! (It doesn't have to match the MySQL password you created before.)

You should then be taken to a page where you can configure torrentflux. In particular, the first line (path) will be marked with an error:
"Path is not Writable -- make sure you chmod +w this path"
You need to change permissions on the download folder:

Code:

$ sudo chmod 777 /var/www/torrentflux/downloads/

You should look over the rest of the settings too. Note that "Port Range" is an important parameter for efficient bit-torrent. You should pick some range (like 45000-46000), and then open up the corresponding range on your router (if any). By allowing connections on that range, you will be able to connect to a larger swarm during downloading, which increases download speed considerably.

Step 5: Dynamic IP

If you have a static IP address, you can skip this step. However most home users have a dynamic IP, meaning that it changes every so often (whenever your ISP feels like it, which may be every day or every couple of months). Thus to connect to your torrentflux remotely, you won't know what IP address to go to. A convenient solution is to use a "domain redirect" service. Basically this service will give you an easy to remember alias, like "user.example.com" which will get you to your machine. In order to have the IP conveniently updated, there are programs that can update your domain redirect automatically.

This tutorial will use "noip" as an example. Similar procedures would apply to other services. I've used noip for quite awhile now, and their service is excellent. You can create a new account:http://www.no-ip.com/newUser.php

Then you can login to "Your No-IP" and go "Add" to create a new host. You get to select the prefix (whatever you want) and select a list of domains from those that No-IP manages. You can then enter your current IP address (usually auto-detected). Let's say you selected "user.no-ip.info". After adding the new host (and waiting a few minutes), you should be able to access your torrentflux using:http://user.no-ip.info/torrentflux/
orhttp://user.no-ip.info:8080/torrentflux/
(if you used a custom port, above).

Of course the real problem with a dynamic IP is that it changes without notice. For this, No-IP provides a piece of software (go to the "Download" section and select "Linux/BSD/Unix"):http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
As before, you need to untar the file, and enter the new directory:

Code:

$ tar -xvzf noip-duc-linux.tar.gz
$ cd noip-2.1.3/

If you are running an "i686 machine" (i.e.: any recent standard desktop PC), then do this:

Code:

$ cp binaries/noip2-Linux noip2
$ sudo make install

And answer the questions (using the email/password that you created the noip account with). The update interval is in minutes (default 30 minutes is fine).

If you are not running an i686 machine (PowerPC, etc.) then you will need to compile the program. If you don't have compilers installed, then install them:

Code:

$ sudo aptitude install build-essential

To compile, while in the "noip2-2.1.3/" direction, just do:

Code:

$ make
$ sudo make install

In either case, you can now run noip by typing:

Code:

$ sudo noip2

To make sure that noip starts everytime the computer boots, edit the file "rc.local" in the "/etc/" directory (note that there is another version of rc.local in "/etc/init.d" but that's not the one you want to edit!):

Code:

$ sudo nano /etc/rc.local

And add a line:

Code:

/usr/local/bin/noip2 &

Be sure to put this line *before* the "exit 0" line at the end!

Now noip will always be running when the computer is turned on, and it will update the your domain name frequently, so that when you go to "http://user.no-ip.info/torrentflux/" you get to your own pesonal torrentflux application.

Step 6: Adding Search Modules
Another neat feature of torrentflux is that it centralizes your torrent searching. You can add modules to torrentflux that enable it to use the search facilities on a number of different trackers. A few modules are given as examples. Other modules are are available on the torrentflux forums:http://www.torrentflux.com/forum/

To add a new module, simply download the file, and move it into the "searchEngines" folder:

Code:

$ mv module.php /var/www/searchEngines/

Conclusion
Hopefully this how-to will be of use to others. I followed these steps on a fresh install of Kubuntu 6.06 and it worked fine.

Last edited by kebes; September 3rd, 2007 at 02:28 AM.
Reason: typo in "cd" command

Re: How-to: Installing Torrent-Flux

Problem solved, I did a little digging around and found this:

Fatal error: Call to undefined function: mysql_connect() in /var/www/html/adodb/drivers/adodb-mysql.inc.php on line 354
This means that your version of php can't connect to the mysql database. Usually installing a package like php-mysql will solve this although if it doesn't then open your php.ini file and find the line like extension=mysql.so, remove the comment from in front, and then restart your webserver.

Re: How-to: Installing Torrent-Flux

Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Warning: Unknown: Failed opening '/var/www/test.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0

Re: How-to: Installing Torrent-Flux

Hi all, I have a problem.

When I browse to http://localhost/test.php, firefox tries to save the php file and doesn't load it in the browser like it should. What could be the problem? I installed php5 and php5-mysql so I don't know why things won't work.