# Ubuntu/Debian Linux编译Deluge安装

## 前言

透過APT安裝的Deluge有兩個缺點：版本老舊 (特別是Debian)、不能指定版本。

此教學通過測試於Ubuntu 16.04/18.04 和 Debian 8/9。

以下將從Deluge官網下載安裝包，並使用Deluged和Deluge-web (WebUI)\
文章下半段有Deluge2.0安裝教學

上次更新日期：2019 年 11 月 9 日

## 安裝編譯libtorrent的工具和依賴

```
apt update
apt install build-essential libboost-system-dev libboost-python-dev libboost-chrono-dev libboost-random-dev libssl-dev automake libtool 
```

編譯安裝Deluge的後端軟件libtorrent-rasterbar：

```
wget https://github.com/arvidn/libtorrent/releases/download/libtorrent_1_1_12/libtorrent-rasterbar-1.1.12.tar.gz
tar xf libtorrent-rasterbar-1.1.12.tar.gz
cd libtorrent-rasterbar-1.1.12
./configure --disable-debug --enable-python-binding --with-libiconv
make -j$(nproc)
make install
ldconfig
```

## 安裝Deluge的工具和依賴

```
apt install python python-twisted python-openssl python-setuptools intltool python-xdg python-chardet geoip-database python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako
```

<http://download.deluge-torrent.org/source/>\
從官網下載Deluge安裝包，若需指定版本請自行修改版本號 (不適用於de2.0)：

```
wget http://download.deluge-torrent.org/source/deluge-1.3.15.tar.xz
```

解壓Deluge安裝包：

```
tar xvJf deluge-1.3.15.tar.xz
cd deluge-1.3.15
```

安裝Deluge：

```
python setup.py build
python setup.py install --install-layout=deb
```

### 設置開機自啟

```
nano /etc/systemd/system/deluged.service
```

輸入以下內容：

```
[Unit]
Description=Deluge Bittorrent Client Daemon
After=network.target
 
[Service]
LimitNOFILE=512000
User=root
ExecStart=/usr/bin/deluged -d
 
[Install]
WantedBy=multi-user.target
```

```
nano /etc/systemd/system/deluge-web.service
```

輸入以下內容：

```
[Unit]
Description=Deluge Bittorrent Client Daemon
After=network.target
 
[Service]
LimitNOFILE=512000
User=root
ExecStart=/usr/bin/deluge-web
 
[Install]
WantedBy=multi-user.target
```

啟用以上設置：

```
systemctl enable deluged.service
systemctl enable deluge-web.service
```

啟動Deluged和WebUI：

```
systemctl start deluged.service
systemctl start deluge-web.service
```

安裝完成！在瀏覽器輸入 <http://你的IP地址:8112> 即可進入DelugeWebUI

WebUI默認密碼：deluge

### 創建下載文件夾和設置權限

```
mkdir /home/Downloads
chmod 777 /home/Downloads
```

Deluge把下載路徑設置到 /home/Downloads就OK了！

## \[嘗鮮] 安裝Deluge2.0正式版

此部分目前僅適用於Ubuntu18。\
Deluge2.0已遷移到Python3，需要的軟件包python-libtorrent會換做python3-libtorrent。

```
apt update
apt install build-essential checkinstall libboost-system-dev libboost-python-dev libboost-chrono-dev libboost-random-dev libssl-dev automake libtool 
```

編譯安裝Deluge的後端軟件libtorrent-rasterbar：

```
wget https://github.com/arvidn/libtorrent/releases/download/libtorrent_1_1_12/libtorrent-rasterbar-1.1.12.tar.gz
tar xf libtorrent-rasterbar-1.1.12.tar.gz
cd libtorrent-rasterbar-1.1.12
./configure --build=x86_64-linux-gnu --prefix=/usr --includedir=\${prefix}/include --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir=\${prefix}/lib/x86_64-linux-gnu --libexecdir=\${prefix}/lib/x86_64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking PYTHON=/usr/bin/python3.6 --enable-python-binding --with-boost-python=boost_python-py36 --with-libiconv --with-boost-libdir=/usr/lib/x86_64-linux-gnu
make -j$(nproc)
make install
python3 setup.py install
ldconfig
```

### 安裝Deluge的工具和依賴

```
apt install python python3-setuptools python-twisted python-openssl python-setuptools intltool python-xdg python-chardet geoip-database python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako
```

&#x20;<http://download.deluge-torrent.org/source/>\
從Github獲取源碼，現時最新版本是Deluge-2.0.3，若需指定版本請自行修改版本號：

```
git clone --branch deluge-2.0.3 https://github.com/deluge-torrent/deluge/
```

安裝Deluge：

```
cd deluge
python3 setup.py build
python3 setup.py install --install-layout=deb
```

### 設置開機自啟

```
nano /etc/systemd/system/deluged.service
```

輸入以下內容：

```
[Unit]
Description=Deluge Bittorrent Client Daemon
Documentation=man:deluged
After=network-online.target

[Service]
Type=simple
UMask=007

ExecStart=/usr/bin/deluged -d

Restart=on-failure

# Time to wait before forcefully stopped.
TimeoutStopSec=300

[Install]
WantedBy=multi-user.target
```

```
nano /etc/systemd/system/deluge-web.service
```

輸入以下內容：

```
[Unit]
Description=Deluge Bittorrent Client Web Interface
Documentation=man:deluge-web
After=network-online.target deluged.service
Wants=deluged.service

[Service]
Type=simple
UMask=027

ExecStart=/usr/bin/deluge-web -d

Restart=on-failure

[Install]
WantedBy=multi-user.target
```

啟用以上設置：

```
systemctl enable deluged.service
systemctl enable deluge-web.service
```

啟動Deluged和WebUI：

```
systemctl start deluged.service
systemctl start deluge-web.service
```

安裝完成！在瀏覽器輸入 <http://你的IP地址:8112> 即可進入DelugeWebUI

WebUI默認密碼：deluge

### 創建下載文件夾和設置權限

```
mkdir /home/Downloads
chmod 777 /home/Downloads
```

Deluge把下載路徑設置到 /home/Downloads就OK了！

## 安装ItConfig

> ltConfig is a plugin for Deluge that allows direct modification to libtorrent settings.
>
> 介绍页面：[http://forum.deluge-torrent.org/viewtopic.php?t=42887](https://forum.deluge-torrent.org/viewtopic.php?t=42887)

到 <https://github.com/ratanakvlun/deluge-ltconfig/releases> 上下载最新的egg发布文件

![](/files/-MCGvLJIt2mcYrf9Kd6l)

进入Deluge WebUI配置页面安装

![](/files/-MCGvSfm-vOkp_vZxV3l)

\
安装完成后启用该插件即可\~

附送二个配置

**Itconfig 参数修改（适用于32G及以上内存独立服务器）**

```
active_limit = 2000;
active_seeds = 2000;
allow_multiple_connections_per_ip: true
auto_upload_slots = false;
cache_buffer_chunk_size = 128;
cache_expiry: 120;
cache_size: 512000;
choking_algorithm: 1;
close_redundant_connections = true;
enable_incoming_utp: false;
enable_outgoing_utp: false;
file_pool_size = 500;
inactivity_timeout = 20;
low_prio_disk: false;
max_failcount = 1;
max_queued_disk_bytes: 262144000;
max_queued_disk_bytes_low_watermark: 131072000;
max_rejects = 10;
optimize_hashing_for_speed = true;
peer_timeout = 20;
read_cache_line_size = 512;
request_timeout = 10;
seed_choking_algorithm: 1;
send_buffer_low_watermark: 13107200;
send_buffer_watermark: 26214400;
send_buffer_watermark_factor: 250;
strict_end_game_mode: false;
use_parole_mode: false;
use_read_cache = true;
write_cache_line_size = 512;
```

**Itconfig 参数修改（适用于8G及以上内存独立服务器）**

```
active_limit = 2000;
active_seeds = 2000;
allow_multiple_connections_per_ip: true
auto_upload_slots = false;
cache_buffer_chunk_size = 128;
cache_expiry: 60;
cache_size: 131000;
choking_algorithm: 1;
close_redundant_connections = true;
enable_incoming_utp: false;
enable_outgoing_utp: false;
file_pool_size = 500;
inactivity_timeout = 20;
low_prio_disk: false;
max_failcount = 1;
max_queued_disk_bytes: 7340032;
max_rejects = 10;
optimize_hashing_for_speed = true;
peer_timeout = 20;
read_cache_line_size = 64;
request_timeout = 10;
seed_choking_algorithm: 1;
send_buffer_low_watermark: 1048576;
send_buffer_watermark: 3145728;
send_buffer_watermark_factor: 150;
strict_end_game_mode: false;
use_parole_mode: false;
use_read_cache = true;
write_cache_line_size = 256;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.ukenn.top/seedbox-wiki-1/chang-jian-ke-hu-duan-an-zhuang-jiao-xue/ubuntudebian-linux-bian-yi-deluge-an-zhuang.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
