Use your Raspberry Pi as an always-on BitTorrent box

In this tutorial we will turn our Raspberry Pi into an always-on BitTorrent box. This will let you have a small, power efficient, torrent server running around the clock.

Why is this a good idea?

A lot of companies offer to download their software and/or files using torrents, and when you downloaded the installer for your Raspberry Pi OS, you could also do this as a torrent.

If you are downloading and/or sharing a lot of files using torrents (legally of course), you might have a dedicated machine, or even your laptop, running for long periods of time solely for this purpose. This can be very power consuming, and that’s why the Raspberry Pi is perfect to use as a dedicated torrent box that can run 24/7. Compared to a laptop or stationary computer, the Pi is very power efficient.



This tutorial uses a Raspberry Pi running RaspBMC as an example system, but you can also use Raspbian. In order proceed I assume that you:

  1. Have a Raspberry Pi running either Raspbian or RaspBMC.
  2. Are able to remotely access your Pi using SSH.
  3. Have some sort of storage connected where you can save files.

If you need help getting started with any of these, you can find more information here:

  1. Getting started with Raspberry Pi – Part 1
  2. Getting started with Raspberry Pi – Part 2 (SSH etc)
  3. Mount a network drive on your Raspberry Pi



Before we start, let’s make sure we have the latest repositories and that our system is up to date:

sudo apt-get update && sudo apt-get upgrade -y
Install and setup Deluge daemon and console
sudo apt-get install deluged
sudo apt-get install deluge-console

Once it is installed, we want to start Deluge and then stop it again. This will create the default configuration files we need.

sudo pkill deluged

Now we have the configuration files we need, and we will edit one of them. Open and edit the ~/.config/deluge/auth file and add the following to the end of the file:

echo "username:password:level" >> ~/.config/deluge/auth

Where user and password are the credentials you want to use for remote access to Deluge, and the level is the access level you want to give that user. You should put this to 10 (which is the full-access/admin level for the Deluge daemon). As an example, I use pi:raspberry:10.

Start the Deluge daemon again, and the Deluge console:


This will bring up the Deluge console window, where we will make some changes to the configuration. Inside the Deluge console, type the following:

config -s allow_remote True
config allow_remote

On the first line we enable remote access to our Deluge daemon, and on the second line we simply double-check that the value is correctly set to True.

Now we have to restart the Deluge daemon again to make the new configurations take effect:

sudo pkill deluged

Now that the Deluge daemon is ready for remote connects, it’s time to install a client on our that we can connect to the daemon.


Install and setup Deluge client

In order to connect to the Deluge daemon running on the Pi, we need to install the Deluge client on our computer:

  • Ubuntu
  • Windows / Mac

If you’re running Ubuntu on your PC, you can install the Deluge client with the following command:

sudo apt-get install deluge

If you are running other Linux distros you can download the necessary package from the official Deluge download page.

Once you have installed the client, start it. The first time we run the client, we have to make a few quick changes. Go to Preferences -> Interface. Under the submenu Classic Mode there’s a checkbox named ‘Enable’. This is checked by default, we need to uncheck it.

Click OK, and restart the client.

Now that the client starts, you will be presented with the Connection Manager. This is where we need to create a connection to the Deluge daemon running on the Pi. Click Add in order to create a new connection, and input the IP of your Pi as well as the username and password that you set for the daemon in the previous section. Leave the port to 58846 as this is the default port.

Once you click add, you will get back to the connection manager and you should see your connection:

Select it and click Connect. Now you are connected to you Deluge daemon on the Pi! We don’t don’t have any torrents there yet, but we’ll get to that soon.


Configure Deluge to use a proxy

Although this section is optional, it is highly recommended that you use a proxy to protect your BitTorrent traffic. There are several reasons why you should use a proxy to shuttle your traffic, and even though you’re not downloading anything illegal it is still better to be safe than sorry. If you want to be anonymous on the Internet, a proxy will help keep eavesdroppers away. By default, Deluge also encrypts all traffic which is good if your ISP is throttling BitTorrent traffic.

If you are suspecting you ISP of throttling your BitTorrent traffic, this tool can help you detect if this is the case.

I am using Private Internet Access as a proxy, and it’s fairly cheap for what you get ($39.95/year). You are of course free to use any service you like, and it’s up to you if you trust using a free service.

Once you have a proxy that you can use, we have to configure Deluge to shuttle the traffic through this proxy. To do this, open Preferences -> Proxy. Set all sections to ‘Socks5 W/ Auth’ and input your credentials. If you are using Private Internet Access’ proxy, the host is and the port 1080.

In order for the changes to take effect, we need to restart the Deluge daemon on the Pi:

sudo pkill deluged 

You will have to reconnect to the Daemon from the client as well.

Test it

Now it’s time to test that the proxy is setup correctly. We will do this by downloading a completely legal torrent from Download the torrent, add it to your queue, and select it to see the IP through which your client is connected. If everything is setup correctly you should see the IP of your proxy instead of your own IP (see the bottom of the picture below).


Configure download folders

Now it’s time to setup the folders where Deluge should download your files. By default, the files will be saved to /home/pi, and this will probably fill up your Pi’s SD card pretty quickly. Instead we are going to save our files to an external storage.

I am using a network drive that I have mounted to /media/network/, but you can use any storage device you like. Just make sure you have permissions to write to it. Mount an SMB network drive on Raspberry Pi will show you how to use a network drive with your Pi.

We are going to create three new folders that we’ll use for Deluge:

.downloading – this is where the active downloads will exist
.completed – once finished downloading, all files will be moved to this folder
.watch – Deluge will watch for newly added .torrent files in this folder, and automatically start them

Decide where you want to create the folders (I have chosen to create these in /media/network/Public/), and run:

sudo mkdir /media/network/Public/.downloading
sudo mkdir /media/network/Public/.completed
sudo mkdir /media/network/Public/.watch

Now open the Preferences -> Downloads section in the client and set the folders to the ones you just created.

You don’t have to restart anything this time.

Test everything

Now we can test that everything is working as it should. Let’s download a large enough file to make sure it runs smoothly, the latest release of Raspberry Pi NOOBS installer (roughly 1.3GB) should be sufficient: NOOBS Latest

Instead of adding it manually through the client, you can try saving the .torrent file to the .watch folder to make sure Deluge starts it automatically.


That’s it! Now you have your very own always-on BitTorrent box running on your Raspberry Pi.

Posted in Uncategorized | Leave a comment

Implementing Single Sign On for Windows with Apache 2.4.x

Implementing Single Sign On for Windows with Apache 2.4.x

* Grab the apache module mod_authnz_sspi from SourceForge

Grab the apache module mod_authnz_sspi from

Unzip the module, and add the files from the bin location to the apache bin folder, and the files from the module folder to the module folder (Apache folder will be something like C:\Programs\Apache\modules).

Make sure you download the right version for your apache install (x64 and x86).

Add the following lines to your Apache configuration file (httdp.conf) – add this at the end of the module configuration:
Load Module sspi_auth_module modules/

Also make sure to uncomment:
LoadModule authn_core_module modules/
LoadModule authz_core_module modules/

* Add a directory block

Options Indexes FollowSymLinks

AllowOverride None
#sspi_auth_module changes – start
Order allow,deny
Allow from all
AuthName “ForLogging”
AuthType SSPI
SSPIAuthoritative On
SSPIOfferBasic On
SSPIOmitDomain Off
Require valid-user
#sspi_auth_module changes – end

This was successfully installed while using:

Windows Server 2012
MySQL 5.6.25
PHP 5.6.0
Apache HTTP Server 2.4.12

Posted in apache, module, mysql, php, sspi, wiki, Windows | Tagged , , , , , | Leave a comment


“There has been an error cropping your image.” error in WordPress when I tried to crop an image for theme header.

The solution is surprisingly easy.

sudo aptget install php5gd

This will install the PHP GD library for image processing.

NOTE: You may need to restart apache server for it to come into effect.

Posted in crop, cropping, image, PHP GD, php5-gd, Wordpress | Leave a comment

Set up a web server on your Pi and install WordPress


Set up a web server on your Pi and install WordPress, a content management system that makes creating websites easier


Apache is a popular web server application you can install on the Raspberry Pi to allow it to serve web pages.

On its own, Apache can serve HTML files over HTTP, and with additional modules can serve dynamic web pages using scripting languages such as PHP.


First install the apache2 package by typing the following command into the terminal:

sudo apt-get install apache2 -y


By default, Apache puts a test HTML file in the web folder. This default web page is served when you browse to http://localhost/ on the Pi itself, or (whatever the Pi’s IP address is) from another computer on the network. To find out the Pi’s IP address, type hostname -I at the command line (or read more about finding your IP address) in our documentation.

Browse to the default web page, either on the Pi or from another computer on the network, and you should see the following:

This means you have Apache working!


This default web page is just an HTML file on the filesystem; it is located at /var/www/index.html. Navigate to this directory in the terminal and have a look at what’s inside:

cd /var/www
ls -al

This will show you:

total 12
drwxr-xr-x  2 root root 4096 Jan  8 01:29 .
drwxr-xr-x 12 root root 4096 Jan  8 01:28 ..
-rw-r--r--  1 root root  177 Jan  8 01:29 index.html

This shows that there is one file in /var/www/ called index.html. The . refers to the directory itself /var/www/, and the .. refers to the parent directory /var/.

The 3rd column shows that, by default the www directory and index.html file are both owned by the root user. In order to edit the file, you must gain root permissions. Either change the owner to your own user before editing (using sudo chown pi: index.html), or edit with sudo (using sudo nano index.html).

Try editing this file and refreshing the browser to see the web page change. Press Ctrl + X and hitEnter to save and exit.


PHP is a preprocessor; it’s code that runs when the server receives a request for a web page. It runs, works out what needs to be shown on the page, then sends that page to the browser. Unlike static HTML, PHP can show different content under different circumstances. Other languages are capable of this, but since WordPress is written in PHP, that’s what we need to use this time. PHP is a very popular language on the web; large projects like Facebook and Wikipedia are written in PHP.

Install the PHP and Apache packages with the following command:

sudo apt-get install php5 libapache2-mod-php5 -y


Create the file index.php:

sudo nano index.php

Put some PHP content in it:

<?php echo "hello world";

Now save the file. Next delete index.html because it takes precendence over index.php:

sudo rm index.html

Refresh your browser. You should see “hello world”. This is not dynamic but it is still served by PHP. Try something dynamic, for example:

<?php echo date('Y-m-d H:i:s');

Or show your PHP info:

<?php phpinfo();


MySQL (pronounced My Sequel or My S-Q-L) is a popular database engine. Like PHP, its overwhelming presence on web servers enhanced its popularity. This is why projects like WordPress use it, and why those projects are so popular.

Install the MySQL Server and PHP-MySQL packages by entering the following command into the terminal:

sudo apt-get install mysql-server php5-mysql -y

When installing MySQL you will be asked for a root password. You’ll need to remember this to allow your website to access the database.


You can download WordPress from using the wget command. Helpfully, a copy of the latest version of WordPress is always available at, so you can grab the latest version without having to look it up on the website. At the time of writing, this is version 4.0.

Navigate to /var/www/, and download WordPress to this location. You’ll need to empty the folder first (be sure to check you’re not deleting files you need before running rm); change the ownership of this folder to the pi user too.

cd /var/www
sudo chown pi: .
sudo rm *

Now extract the tarball, move the contents of the folder it extracted (wordpress) to the current directory and remove the (now empty) folder and the tarball to tidy up:

tar xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz

Running the ls or (tree -L 1) command here will show you the contents of a WordPress project:

├── index.php
├── license.txt
├── readme.html
├── wp-activate.php
├── wp-admin
├── wp-blog-header.php
├── wp-comments-post.php
├── wp-config-sample.php
├── wp-content
├── wp-cron.php
├── wp-includes
├── wp-links-opml.php
├── wp-load.php
├── wp-login.php
├── wp-mail.php
├── wp-settings.php
├── wp-signup.php
├── wp-trackback.php
└── xmlrpc.php

This is the source of a default WordPress installation. The files you edit to customise your installation belong in the wp-content folder.


To get your WordPress site set up, you need a database. Run the mysql command in the terminal and provide your login credentials (e.g. username root, password password):

mysql -uroot -ppassword

Here I have provided my password (the word password) on the command line; there is no space between -p and your password.

Alternatively you can simply supply an empty -p flag and wait to be asked for a password:

mysql -uroot -p

Now you will be prompted to enter the root user password you created earlier.

Once you’re connected to MySQL, you can create the database your WordPress installation will use:

mysql> create database wordpress;

Note the semi-colon ending the statement. On success you should see the following message:

Query OK, 1 row affected (0.00 sec)

Exit out of the MySQL prompt with Ctrl + D.


You need to find out your Pi’s IP address to access it in the browser, so in a terminal type the command hostname -I.

Navigate to http://YOUR-IP-ADDRESS e.g. in the web browser on your Pi.

You should see a WordPress error page; this is good! Click the big button marked Create a Configuration File followed by the Let's go! button on the next page.

Now fill out the basic site information as follows:

Database Name:      wordpress
User Name:          root
Password:           <YOUR PASSWORD>
Database Host:      localhost
Table Prefix:       wp_

Upon successful database connection, you will be given the contents of your wp-config.php file:

Copy this text, return to the terminal on the Pi and edit the file with nano wp-config.php. Paste the text into this file, and save and exit with Ctrl + X, then Y for yes and Enter.

Now hit the Run the install button.


Now you’re getting close.

Fill out the information: give your site a title, create a username and password, put in your email address and untick the search engines box. Hit the Install WordPress button, then log in using the account you just created.

Now you’re logged in and have your site set up, you can see the website by visiting your IP address in the browser on the Pi or another computer on the network. To log in again (or on another computer), go to http://YOUR-IP-ADDRESS/wp-admin.


It’s recommended that you change your permalink settings to make your URLs more friendly. To do this, log in to WordPress and go to the dashboard. Go to Settings then Permalinks. Select thePost name option and click Save Changes. After saving, you will be prompted to update your.htaccess file. You probably don’t have one yet, so add one in /var/www/ by typing nano .htaccess; note this is a hidden file, so it starts with a dot. Then paste in the contents provided:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Save the file and return to the website homepage. Click on the post title or the sample page link and you’ll probably see a Not Found error page. This is because the rewrite module has not been enabled in Apache. To do this, enter sudo a2enmod rewrite.

You’ll also need to tell the virtual host serving the site to allow requests to be overwritten. Do this by editing the virtual host file (with root permissions): sudo nano /etc/apache2/sites-available/default; also, change the AllowOverride setting on line 11 (inside the <Directory /var/www/> block) from None to All. Save the file and then restart Apache with sudo service apache2 restart. Once it’s restarted, refresh the page and it should load successfully. Now posts have URLs like /hello-world/ instead of /?p=123, and pages have URLs like /sample-page/instead of /?page_id=2.


WordPress is very customisable. By clicking your site name in the WordPress banner along the top of the page (when logged in), you’ll be taken to the Dashboard. From here you can change the theme, add pages and posts, edit the menu, add plugins and lots more. This is just a taster for getting something interesting set up on the Raspberry Pi’s web server.

Posted in apache, html, http, mysql, php, Raspberry PI, Raspian, server, setup, web, Wordpress, www | Leave a comment

Recovering from GRUB rescue prompt – Dual boot problems – Linux Mint/Ubuntu

I’ve found out that you can get this grub rescue prompt error from dual booting from a single drive containing two or more Operating Systems or having two or more hard drives each containing a separate OS and using a selector switch to select between them.

The easiest way to solve dual boot problems is to use Boot-Repair (IMHO).

What is Boot-Repair?

Boot-Repair is a simple tool to repair frequent boot issues you may encounter in Linux Mint/Ubuntu like when you can’t boot Linux Mint/Ubuntu after installing Windows or another Linux distribution, or when you can’t boot Windows after installing Linux Mint/Ubuntu, or when GRUB is not displayed anymore, some upgrade breaks GRUB, etc.

Installation and use:

  • Boot into Ubuntu or Linux Mint Live CD or USB

  • Open terminal and run following commands:

    sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
    sudo apt-get install -y boot-repair && boot-repair
  • Once done Boot-Repair will open with two options choose the first option (Recommended repair).

    enter image description here

  • When repair is finished, Save the URL that appeared, Then reboot.

    enter image description here

  • If the repair didn’t succeed, Share the URL on askubuntu, Linux Mint forum or any other help forum for more help.

Posted in Boot-Repair, Dual boot, grub, linux, Linux Mint, Ubuntu | Leave a comment

How to prevent the GRUB menu from showing up in the beginning of boot?

You need to edit the file at /etc/default/grub to prevent showing the grub menu.

By default, the entries in that files look like this.

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  • Remove the # mark from second line, and

After changes, the required portion of the file will look like this

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  • Then run sudo update-grub command in the terminal, and reboot to see the result.
Posted in boot, grub, linux, Linux Mint, Ubuntu | Leave a comment

How to make Ubuntu and Linux Mint ready to play encrypted Blu-Ray’s on VLC and XBMC

This tutorial guide is applicable for Ubuntu, Linux Mint and also applies to any Debian based distro.
For other Linux distros please substitute apt-get for your package manager.

Install Instructions:
bash 5249

During the installation you have the option to install the latest version of VLC media player. To complete the installation you have to reboot your machine. When you have completed the installation process you are able to play Blu-Ray’s but not to trans-code them. Using the VLC media player you can run encrypted Blu-Ray’s by choosing BluRay as “Disc Selection” (check box “No disc menus”) and by selecting the related disk drive.

Posted in Blu-Ray, linux, Linux Mint, Ubuntu, VLC, XBMC | Leave a comment