2023-05-25_00-07.png

本教程适用于Ubuntu16 +及Debian 9 +系列

本教程支持的编译版本:qBittorrent3.X.X,qBittorrent4.X.X

旧版本的ubuntu,如14.04建议使用3.3.11 版本及以下对应版本

目前很多PT站不支持4.2.x,因此推荐安装4.1.9,本教程以4.1.9为例,其它版本类推。

1.安装依赖环境

1.1.安装依赖包

apt-get update
apt-get install libboost-dev libboost-system-dev build-essential
apt-get install libboost-chrono-dev libboost-random-dev libssl-dev libgeoip-dev
apt-get install git pkg-config automake libtool nano  zlib1g-dev

1.2.安装 Qt5 库

apt-get install qtbase5-dev qttools5-dev-tools

1.3.安装 python 和 GeoIP 数据库

apt-get install python
apt-get install geoip-database

2.安装 Libtorrent

2.1.下载 Libtorrent 包

git clone https://github.com/arvidn/libtorrent.git
cd libtorrent

2.2.编译 Libtorrent
编译 1.1.X 的 libtorrent,1.1.X 最低支持到 4.1.4+ 版本的 qb

git checkout RC_1_1
./autotool.sh
./configure --disable-debug --enable-encryption --with-libgeoip=system CXXFLAGS=-std=c++11  
make && make install
ldconfig

如果需要使用 4.1.3 以及更低版本的 qbittorrent,请在编译时改变第一条命令如下

git checkout RC_1_0

这样编译的就是 1.1.X 的 libtorrent

3.安装 qBittorrent
3.1.下载 QB 安装包
QB 各版本下载:https://github.com/qbittorrent/qBittorrent/releases

如编译安装最新版4.1.9 版本的 qBittorrent

wget https://github.com/qbittorrent/qBittorrent/archive/release-4.1.9.tar.gz
tar -xzvf release-4.1.9.tar.gz
cd qBittorrent-release-4.1.9

如需编译其它版本类似,只需修改链接上对应的版本号就可以了!www.ufans.top推荐。

3.2.编译 qBittorrent

./configure --prefix=/usr --disable-gui    
make && make install

4.关闭防火墙
方法自行百度,这里只是提醒一下,正常安装完后没反应或无法运行,大部分是端口的问题。

找不出原因时,可以完全关闭防火墙,调试好后再打开放行需要的端口。

apt-get remove ufw
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -F

5.运行 qBittorrent

5.1.初始化 QB(设置中文)
在qb的安装目录下执行以下命令运行 QB

qbittorrent-nox

运行后会提示输入,输入 y,然后回车即可,
浏览器打开地址,默认地址: http://IP 地址:8080,默认用户名admin,默认密码adminadmin
打开设置,在 WEBUI 里将语言改成中文,修改默认端口8080,以及用户名和密码。
然后在 shell 里按 Ctrl+C 结束 QB 程序,再次输入命令运行 QB,配置即可生效。

5.2.后台运行 QB
因为直接运行 QB,退出 shell 窗口的话就会关闭,所以我们可以用nohup的方式运行 QB

nohup qbittorrent-nox &

这样 QB 就已经稳定在后台运行了,即使你关闭 shell 也不会结束的。

5.3.设置开机启动
查看rc-local 服务是否打开
如果rc-local 服务是关闭的,我们需要打开它。
创建新的 rc.local 文件

cat >> /etc/rc.local << "EOF"
#!/bin/sh -e
nohup qbittorrent-nox &
exit 0
EOF

给 rc.local 文件运行权限并打开 rc-local 服务

chmod +x /etc/rc.local 
systemctl start rc-local

以上就是 Debian9 下配置 QB 开机启动的方法,有问题欢迎留言!

6.常见问题

6.1 提示 Qt5 qmake 版本低
当在低版本系统上编辑 qBittorrent4.X.X 时,由于 apt 安装的 QT5 版本低,就会报此错误!

checking for Qt5 qmake >= 5.5.1… not found
configure: error: Could not find qmake
如果是Debian的低版本系统,可以依次执行以下命令解决问题

apt-get remove qtbase5-dev qttools5-dev-tools
echo "deb http://deb.debian.org/debian stretch main" >> /etc/apt/sources.list
apt-get update
apt-get install qtbase5-dev qttools5-dev-tools
sed -i '$d' /etc/apt/sources.list
apt-get update

注意:其中的/etc/apt/sources.list 是存放你的 apt 源的文件,如果你的系统不是这个文件,请自行更改!

最后修改:2023 年 06 月 02 日
如果觉得我的文章对你有用,请随意赞赏