编译qbittorrent4.2建议直接上Debian10,旧系统包括Debian9在内因为官方存储库内的QT库版本过低(至少要5.9)将导致编译失败

一、安装编译环境

apt -y update
apt -y install build-essential zlib1g-dev pkg-config automake libtool libboost-dev libboost-system-dev libboost-chrono-dev libboost-random-dev libssl-dev libgeoip-dev qtbase5-dev qttools5-dev-tools libqt5svg5-dev unzip

二、安装打包工具

apt -y install ruby ruby-dev rubygems build-essential
gem install fpm

三、编译打包 libtorrent-rasterbar

wget https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_2_3/libtorrent-rasterbar-1.2.3.tar.gz
tar -xvf libtorrent-rasterbar-1.2.3.tar.gz
cd libtorrent-rasterbar-1.2.3
./configure --enable-encryption --disable-debug CXXFLAGS="-std=c++14"
make -j$(nproc)

不打包直接安装的话执行:
make install
ldconfig -v

打包的话在 make 后不要执行 make install,换成下面的命令,将 libtorrent-rasterbar 安装到临时目录:
mkdir -p /tmp/libtorrent-rasterbar
make install DESTDIR=/tmp/libtorrent-rasterbar

之后使用 fpm 创建 deb:
fpm -s dir -t deb -C /tmp/libtorrent-rasterbar -m "user " --url "https://znov.org" --description "Development files for libtorrent-rasterbar" --vendor "user" -n libtorrent-rasterbar -v 1.2.3 -p libtorrent-rasterbar_1.2.3_amd64.deb usr/local

此时目录下会有个 libtorrent-rasterbar_1.2.3_amd64.deb
接着安装:dpkg -i libtorrent-rasterbar_1.2.3_amd64.deb

四、编译打包 qBittorrent 4.2.1

wget https://github.com/qbittorrent/qBittorrent/archive/release-4.2.1.zip
unzip release-4.2.1.zip
cd qBittorrent-release-4.2.1
./configure --prefix=/usr --disable-gui CXXFLAGS="-std=c++14"
make -j$(nproc)

同理,不打包直接安装的话执行:
make install
ldconfig -v

打包的话在 make 后不要执行 make install,换成下面的命令,将 qbittorrent-nox 安装到临时目录:
mkdir -p /tmp/qbittorrent-nox
make install INSTALL_ROOT=/tmp/qbittorrent-nox

之后使用 fpm 创建 deb:
fpm -s dir -t deb -C /tmp/qbittorrent-nox -m "user " --url "https://znov.org" --description "bittorrent client based on libtorrent-rasterbar (without X support)" --vendor "user" -n qbittorrent-nox -v 4.2.1 -p qbittorrent-nox_4.2.1_amd64.deb -d "libtorrent-rasterbar >= 1.2.3" -d "zlib1g-dev >= 1:1.2.0" -d "libstdc++6 >= 5.2" -d "libqt5xml5 >= 5.2.0" -d "libqt5network5 >= 5.9.0~beta" -d "libqt5core5a >= 5.11.0~rc1" -d "libboost-system1.67.0" usr/

ps:zlib1g-dev、libstdc++6、libqt5xml5、libqt5network5、libqt5core5a、libboost-system 根据第 1 步安装完成的实际版本号填写

五、配置 Systemd Service

nano /etc/systemd/system/qbittorrent.service

[Unit]
Description=qBittorrent Daemon Service
Documentation=man:qbittorrent-nox(1)
Wants=network-online.target
After=network-online.target nss-lookup.target

[Service]
Type=simple
User=root
ExecStart=/usr/bin/qbittorrent-nox
TimeoutStopSec=infinity

[Install]
WantedBy=multi-user.target

开启启动:systemctl enable qbittorrent
取消开机启动:systemctl disable qbittorrent
启动:systemctl start qbittorrent
状态:systemctl status qbittorrent
停止:systemctl stop qbittorrent

六、Nginx 反代 qBittorrent-nox

location / {
    proxy_pass https://0.0.0.0:8080/;
    proxy_hide_header Content-Security-Policy;
    proxy_set_header    X-Real-IP           $remote_addr;
    proxy_set_header    X-Forwarded-Host    $server_name:$server_port;
    proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;
    proxy_set_header    X-Forwarded-Proto   $scheme;
    proxy_set_header    X-Forwarded-Ssl     on;    
    proxy_set_header   Referer           '';
    proxy_set_header   Origin            '';
    proxy_hide_header       Referer;
    proxy_hide_header       Origin;
    add_header         X-Frame-Options   "SAMEORIGIN"; 
}

七、重置密码

nano ~/.config/qBittorrent/qBittorrent.conf
找到 WebUI\Password_PBKDF2 这一行删除重启 qbittorrent

附已经打包好的 deb

此处内容需要评论回复后(审核通过)方可阅读。

注:一 ~ 四步摘自萝莉论坛

Last modification:March 1st, 2020 at 10:51 am
如果觉得我的文章对你有用,请随意赞赏