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:
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.
sudo aptitude install torrentflux
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.
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:
$ sudo aptitude install apache2
$ sudo aptitude install php5
$ sudo aptitude install mysql-server
$ sudo aptitude install php5-mysql
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:
And put in this text:
$ sudo nano /var/www/test.php
Then go to http://localhost/test.php
Test page<br />
echo 'If you can see this text, then PHP is working.';
If you see the "...then PHP is working" message then all is well.
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:
(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.)
$ mysqladmin -uroot password 'new-password'
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:
Then test your setup by using a web browser to check:
(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:
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).
port start: 80
port end: 80
type (TCP/UDP/Both): Both
Forward to: 192.168.1.101
Then you should test again by visiting your *external* IP address:
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:
And add a line that says:
$ sudo nano /etc/apache2/apache2.conf
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:
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".
$ sudo /etc/init.d/apache2 restart
After doing this, test your webserver by going to:
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.
Step 3: Get Torrent-Flux
Now you can go download torrentflux:
The files are hosted by SourceForge:
Once the file is downloaded, you can untar it in the usual way:
Inside the newly-created "torrentflux_2.1/" directory, you will find a file called "INSTALL" with detailed instructions of what to do next. We'll now go through those steps.
$ tar -xvzf torrentflux_2.1.tar.gz
Step 4: Install Torrent-Flux
4.a Copy files.
Torrent-flux is 'simply' a bunch of PHP files (server-interpreted web-files). For them to work, all you really need to do is copy them into your web-folder:
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.
$ sudo mkdir /var/www/torrentflux/
$ sudo chown user:user /var/www/torrentflux/
$ cd ~/Desktop/torrentflux_2.1/html/
$ cp -r * /var/www/torrentflux/
We also need MySQL setup properly. Create a database for 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):
$ mysqladmin -uroot -p create torrentflux
And upload the torrentflux structure to MySQL:
$ cd ~/Desktop/torrentflux_2.1/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/
$ mysql -uroot -p torrentflux < mysql_torrentflux.sql
Now you need to tell torrentflux the password you set for your MySQL system. So you edit the file:
Near the top of the file, you'll see lines that read:
$ sudo nano /var/www/torrentflux/config.php
You can modify the "db_pass" line with the password you selected before.
$cfg["db_user"] = "root"; // username for your MySQL database
$cfg["db_pass"] = ""; // password for database
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:
Of course instead of 'secret' you should use better password. Now you edit the torrentflux configuration:
$ mysql -uroot -p
mysql> use mysql;
mysql> INSERT INTO user (Host,User,Password) VALUES('localhost','torfluxuser',PASSWORD('secret'));
mysql> FLUSH PRIVILEGES;
mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON torrentflux.* TO 'torfluxuser'@'localhost';
And update the lines:
$ sudo nano /var/www/torrentflux/config.php
Obviously you can call your torrentflux user whatever you want, and set the password to whatever you like. Just make sure that the entry in MySQL and in torrentflux match!
$cfg["db_user"] = "torfluxuser"; // username for your MySQL database
$cfg["db_pass"] = "secret"; // password for database
4.d First login.
Now you can go to your torrentflux page, using a web-browser:
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:
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.
$ sudo chmod 777 /var/www/torrentflux/downloads/
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.
There are companies that offer free domain redirection services. An extensive list can be found here:
The two most popular are DynDNS:
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:
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:
(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"):
As before, you need to untar the file, and enter the new directory:
If you are running an "i686 machine" (i.e.: any recent standard desktop PC), then do this:
$ tar -xvzf noip-duc-linux.tar.gz
$ cd noip-2.1.3/
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).
$ cp binaries/noip2-Linux noip2
$ sudo make install
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:
To compile, while in the "noip2-2.1.3/" direction, just do:
$ sudo aptitude install build-essential
In either case, you can now run noip by typing:
$ sudo make install
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!):
And add a line:
$ sudo nano /etc/rc.local
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:
To add a new module, simply download the file, and move it into the "searchEngines" folder:
$ mv module.php /var/www/searchEngines/
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.