Documentation by Dysphunkional


This guide will show how to install the Deluge bittorrent client in FreeBSD 9.x. The binaries for Deluge include the GTK client and require a full GUI desktop environment which is overkill for a server or jail. To install Deluge with just the server and web interface we will need to install from source. We don’t want to have to compile all of the dependencies for Deluge so we will install portmaster and use that to install deluge from source and portmaster will automatically install binaries for dependencies if they are up to date. Be sure to install or upgrade the ports collection and portmaster before you begin.

Create a Deluge User

If you are installing Deluge in a FreeNAS jail see the instructions in the next section. Otherwise just run this command:

pw useradd -n deluge -c "Deluge BitTorrent Client" -s /sbin/nologin -w no

FreeNAS Jail

If you are installing in a FreeNAS jail create a new user. Set the Username to “deluge” and set the Full Name to “Deluge BitTorrent Client”. Change the Shell to nologin and check the Disable password login box. Keep track of the User ID, you’ll need it later.
FreeNAS Add Deluge User
In the command line of the jail create a user with the following command replacing with the User ID from the FreeNAS webUI:

pw useradd -n deluge -u <ID> -c "Deluge BitTorrent Client" -s /sbin/nologin -w no

Create a directory to store the deluge config files

mkdir -p /home/deluge/.config/deluge
chown -R deluge:deluge /home/deluge/

Install Deluge

portmaster -P net-p2p/deluge

Uncheck the box for GTK and accept the defaults for all dependencies.

Edit the startup script for the deamon to add deluge web interface

nano -wc /usr/local/etc/rc.d/deluged

Now copy the following into the file:


# $FreeBSD: net-p2p/deluge/files/ 300897 2012-07-14 14:29:18Z beat $
# PROVIDE: deluged
# KEYWORD: shutdown
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
# deluged_enable (bool):        Set to NO by default.
#                               Set it to YES to enable deluged.
# deluged_user (str):           The UNPRIVILEGED user to run as
# deluged_flags (str):          Set as needed
#                               See deluged(1) for more information
# deluged_confdir (path):       Set to /home/$deluged_user/.config/deluge
#                               by default
# deluged_loglevel (str):       Set to "error" by default
# deluged_logfile (path):       Set to /var/tmp/deluged.log by default
# deluged_weblogfile (path):    Set to /var/tmp/deluge-web.log by default

. /etc/rc.subr





        if [ "$deluged_user" = 'asjklasdfjklasdf' ]; then
                err 1 "You must set deluged_user to a real, unprivileged user"

        if [ ! -d "/var/run/${name}" ]; then
                if [ -e "/var/run/${name}" ]; then
                        unlink /var/run/${name}
                mkdir -p /var/run/${name}

        if [ ! -d "/var/run/${webname}" ]; then
                if [ -e "/var/run/${webname}" ]; then
                        unlink /var/run/${webname}
                mkdir -p /var/run/${webname}

        chmod 0755 /var/run/${name}
        chown -R $deluged_user /var/run/${name}
        chmod 0755 /var/run/${webname}
        chown -R $deluged_user /var/run/${webname}

        if [ ! -f "${webpidfile}" ]; then
                su -m ${deluged_user} -c "${webcommand} ${webcommand_args}"
                echo "Starting ${webname}."
                echo `/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ {print $2}'` > $webpidfile
                GETPROCESSPID=`/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ && !/sh/ {print $2}'`
                PIDFROMFILE=`cat ${webpidfile}`
                if [ "$GETPROCESSPID" = "$PIDFROMFILE" ]; then
                        echo "${webname} already running with PID: ${PIDFROMFILE} ?"
                        echo "Remove ${webpidfile} manually if needed."
                        rm -f ${webpidfile}
                        su -m ${deluged_user} -c "${webcommand} ${webcommand_args}"
                        echo "Starting ${webname}."
                        echo `/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ {print $2}'` > $webpidfile

        PIDFROMFILE=`cat ${webpidfile}`
        kill ${PIDFROMFILE}

        [ -e "$webpidfile" ] && unlink $webpidfile
        [ -d "${webpidfile%/pid}" ] && rmdir ${webpidfile%/pid}

        [ -e "$deluged_weblogfile" -a ! -s "$deluged_weblogfile" ] &&
                unlink $deluged_weblogfile

        [ -e "$pidfile" ] && unlink $pidfile
        [ -d "${pidfile%/pid}" ] && rmdir ${pidfile%/pid}

        [ -e "$deluged_logfile" -a ! -s "$deluged_logfile" ] &&
                unlink $deluged_logfile

load_rc_config $name

: ${deluged_enable:="NO"}
: ${deluged_user:="asjklasdfjklasdf"}
: ${deluged_confdir:="/home/${deluged_user}/.config/deluge"}
: ${deluged_loglevel:="error"}
: ${deluged_logfile:="/var/tmp/${name}.log"}
: ${deluged_weblogfile:="/var/tmp/${webname}.log"}

command_args="-c $required_dirs -L $deluged_loglevel -l $deluged_logfile -P $pidfile"
webcommand_args="-f -c $required_dirs -L $deluged_loglevel -l $deluged_weblogfile"

run_rc_command "$1"

Set permisssions on the script

chmod 555 /usr/local/etc/rc.d/deluged

Set the deamons run at startup

echo 'deluged_enable="YES"' >> /etc/rc.conf
echo 'deluged_user="deluge"' >> /etc/rc.conf

Start and stop the deluge deamon to create the default config files

/usr/local/etc/rc.d/deluged start
/usr/local/etc/rc.d/deluged stop

Add User to the authentication file

The next step is to create a Deluge user for clients/UIs to access the daemon remotely.
The auth file should contain lines with only ‘::’, replacing and with your choice and with the desired authentication level.
You can use your favourite text editor to achieve this or can be done with a one-line echo command e.g.:

echo "alice:MyC0mpL3xPass:10" >> /home/deluge/.config/deluge/auth

Allow remote connections to deluge

edit /home/deluge/.config/deluge/core.conf

 nano -wc /home/deluge/.config/deluge/core.conf

Change “allow_remote” from false to true.

  "file": 1,
  "format": 1
  "info_sent": 0.0,
  "lsd": true,
  "max_download_speed": -1.0,
  "send_info": false,
  "natpmp": true,
  "move_completed_path": "/root",
  "peer_tos": "0x00",
  "enc_in_policy": 1,
  "queue_new_to_top": false,
  "ignore_limits_on_local_network": true,
  "rate_limit_ip_overhead": true,
  "daemon_port": 58846,
  "torrentfiles_location": "/root",
  "max_active_limit": 8,
  "geoip_db_location": "/usr/local/share/GeoIP/GeoIP.dat",
  "upnp": true,
  "utpex": true,
  "max_active_downloading": 3,
  "max_active_seeding": 5,
  "allow_remote": true,
  "outgoing_ports": [
  "enabled_plugins": [],
  "max_half_open_connections": 50,
  "download_location": "/root",
  "compact_allocation": false,
  "max_upload_speed": -1.0,
  "plugins_location": "/home/deluge/.config/deluge/plugins",
  "max_connections_global": 200,
  "enc_prefer_rc4": true,
  "cache_expiry": 60,
  "dht": true,
  "stop_seed_at_ratio": false,
  "stop_seed_ratio": 2.0,
  "max_download_speed_per_torrent": -1,
  "prioritize_first_last_pieces": false,
  "max_upload_speed_per_torrent": -1,
  "auto_managed": true,
  "enc_level": 2,
  "copy_torrent_file": false,
  "max_connections_per_second": 20,
  "listen_ports": [
  "max_connections_per_torrent": -1,
  "del_copy_torrent_file": false,
  "move_completed": false,
  "autoadd_enable": false,
  "proxies": {
    "peer": {
      "username": "",
      "password": "",
      "hostname": "",
      "type": 0,
      "port": 8080
    "web_seed": {
      "username": "",
      "password": "",
      "hostname": "",
      "type": 0,
      "port": 8080
    "tracker": {
      "username": "",
      "password": "",
      "hostname": "",
      "type": 0,
      "port": 8080
    "dht": {
      "username": "",
      "password": "",
      "hostname": "",
      "type": 0,
      "port": 8080
  "dont_count_slow_torrents": false,
  "add_paused": false,
  "random_outgoing_ports": true,
  "max_upload_slots_per_torrent": -1,
  "new_release_check": false,
  "enc_out_policy": 1,
  "seed_time_ratio_limit": 7.0,
  "remove_seed_at_ratio": false,
  "autoadd_location": "/root",
  "max_upload_slots_global": 4,
  "seed_time_limit": 180,
  "cache_size": 512,
  "share_ratio_limit": 2.0,
  "random_port": true,
  "listen_interface": ""

Start the deluge deamon

/usr/local/etc/rc.d/deluged start

Log Into Deluge-Web

Using your web browser go to http://IPAddress:8112 and log in with the password deluge. If you don’t know the IP address of the jail running Deluge you can run the ifconfig command from within the jail to find it.


Look in the output for the address after “inet”. My jail’s address is in the example below:

em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 08:00:27:97:f5:4b
        inet netmask 0xffffff00 broadcast
        media: Ethernet autoselect (1000baseT )
        status: active
ipfw0: flags=8801<UP,SIMPLEX,MULTICAST> metric 0 mtu 65536
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384

After logging into the web interface the first time you will be asked to change your password.
Deluge-Web Change Password Prompt
Click the Yes button to be taken to the config page where you can change your password. You may have to click the Connect button on a window asking what server to connect to first.
To change the password for the web interface put the old password, deluge in the Old Password box and enter you new password in the New Password and Confirm Password boxes then click the Change button.
Deluge-Web Change Password
You should get a box saying that your password was successfully changed.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: