---
title: Compiling qbittorrent nox for CentOS from source
date: 2019-03-15 20:51:36
tags: qbittorrent
---
# 序言

# 依赖版本

## 版本
qBittorrent的源代码库有200M多兆所以如果不是追求最新版本与网速不理想的话建议下载打包好的源代码。 现在 qBittorrent在我写文章的时候已经发展到4.15这个版本了。
libtorrent-1.1.10 最低
Gcc版本要新版本
<!--more-->
# 内容
## 一 环境准备
1.安装依赖项
```
yum -y groupinstall "Development Tools"
yum -y install qt-devel boost-devel openssl-devel qt5-qtbase-devel qt5-linguist
```
2.libtorrent版本1.1.12
```
wget https://github.com/arvidn/libtorrent/releases/download/libtorrent_1_1_12/libtorrent-rasterbar-1.1.12.tar.gz
```
3.升级GCC编译器CentOS 7 升级gcc 7
升级时候因个人网速快慢。
```
sudo yum install centos-release-scl
sudo yum install devtoolset-7-gcc*
scl enable devtoolset-7 bash
which gcc
gcc --version
```
这种方法同样适用于安装gcc6,只需要将上面命令中7改成6即可。详情请参考: https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/
centos7默认gcc版本

cnetos7升级后的版本

## 二 编译安装
此时你的目录下应该有这些文件,``libtorrent-rasterbar-1.1.12.tar.gz``与``qBittorrent``qBittorren为什么是一个目录嘞,我下的仓库源码包有200m多兆,哭

### 编译libtorrent
```
tar -zxf libtorrent-rasterbar-1.1.12.tar.gz
cd libtorrent-rasterbar-1.1.12
./configure --prefix=/usr CXXFLAGS=-std=c++11
make
make install
ln -s /usr/lib/pkgconfig/libtorrent-rasterbar.pc /usr/lib64/pkgconfig/libtorrent-rasterbar.pc
ln -s /usr/lib/libtorrent-rasterbar.so.9 /usr/lib64/libtorrent-rasterbar.so.9
cd ~
```
0x1执行make

0x2执行make install

0x3别忘记创建链接

### 编译qBittorrent
```
cd qBittorrent
./configure --prefix=/usr --disable-gui CPPFLAGS=-I/usr/include/qt5
make
make install
cd ~
```
0x1执行./configure省略后

0x2执行make后

0x3执行make install

默认我是用root这个用户编译的文件也下载到root的家目录
# 编译后的收尾
## 打开防火墙
```
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=8080/udp --permanent
firewall-cmd --reload
```

## 先执行一遍程序
在#下输入``qbittorrent-nox ``
Press 'y' key to accept and continue...
输入``y``回车同意

## 设置成systemctl 服务
```
cat <<EOF | sudo tee /usr/lib/systemd/system/qbittorrent.service
[Unit]
Description=qbittorrent torrent server
[Service]
User=root
ExecStart=/usr/bin/qbittorrent-nox
Restart=on-abort
[Install]
WantedBy=multi-user.targe
EOF
```

复制全部然后粘贴回车,然后执行以下命令
```
systemctl daemon-reload
systemctl restart qbittorrent
systemctl enable qbittorrent
```

不知道为什么启动重启停止没有问题,开机启动反而有问题。[参考](https://github.com/qbittorrent/qBittorrent/wiki/Setting-up-qBittorrent-as-a-daemon-on-CentOS-7)
# 后期结尾
然后在浏览器里输入http://ip:端口 访问控制端
用户名admin密码adminadmin

对于qbittorrent仓库大国内下载速度慢,可以下载已经打包好的源代码,如果追求最新,可以,我记得国内coding托管可以克隆GitHub仓库,克隆后再在coding上下载,迂回办法,有条件的同学可以试试其他的,道路千万条,安全第一条,行车不规范,亲人两行泪。