1、安装aira2
方法一:通过epel源安装,不推荐,gnutls版本太旧
cat << EOF >> /etc/yum.repos.d/epel.repo
[epel]
name=Epel rebuild for armhfp
baseurl=https://armv7.dev.centos.org/repodir/epel-pass-1/
enabled=1
gpgcheck=0
EOF
yum install aria2 -y
方法二:编译
yum install -y gnutls-dev nettle-dev gmp-devel libssh2-devel c-ares-devel libxml2-devel zlib-devel sqlite-devel gcc-c++ openssl openssl-devel
提示说gnutls找不到都没关系,编译用的是openssl
从github上找源码,https://github.com/aria2/aria2/releases
wget https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0.tar.gz
tar xzvf aria2-1.35.0.tar.gz
cd aria2-1.35.0
./configure ARIA2_STATIC=yes --without-gnutls --with-openssl --prefix=/usr/local/aria2
make && make install
ln -s /usr/local/aria2/bin/aria2c /usr/bin/aria2c
2、安装第三方的界面
我用的是https://github.com/mayswind/AriaNg
到https://github.com/mayswind/AriaNg/releases找到要下载的版本,我用的是AllInOne的版本
#安装nginx
yum install -y nginx
#下载AriaNG
wget https://github.com/mayswind/AriaNg/releases/download/1.1.6/AriaNg-1.1.6-AllInOne.zip
unzip AriaNg-1.1.6-AllInOne.zip -d aria-ng
#放到nginx默认配置文件中root对应的路径
mv ./aria-ng /usr/share/nginx/html
#启动nginx
systemctl start nginx
#关闭防火墙
systemctl stop firewalld
3、aria2配置文件如下
P3TERX/aria2.conf: Aria2 配置文件 | OneDrive & Google Drvive 离线下载 | 百度网盘转存 (github.com)
#后台运行
daemon=true
## 文件保存相关 ##
# 文件保存目录 此处文件保存目录自行设定
dir=/home/Ariaer
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
disk-cache=32M
# 断点续传
continue=true
# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc
# 预分配所需时间: none < falloc ? trunc < prealloc
# falloc和trunc则需要文件系统和内核支持
# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项
#file-allocation=falloc
## 下载连接相关 ##
# 最大同时下载任务数, 运行时可修改, 默认:5
#max-concurrent-downloads=5
# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=15
# 整体下载速度限制, 运行时可修改, 默认:0(不限制)
#max-overall-download-limit=0
# 单个任务下载速度限制, 默认:0(不限制)
#max-download-limit=0
# 整体上传速度限制, 运行时可修改, 默认:0(不限制)
#max-overall-upload-limit=0
# 单个任务上传速度限制, 默认:0(不限制)
#max-upload-limit=0
# 禁用IPv6, 默认:false
disable-ipv6=true
# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M
# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载
min-split-size=10M
# 单个任务最大线程数, 添加时可指定, 默认:5
split=10
## 进度保存相关 ##
# 从会话文件中读取下载任务
input-file=/home/Ariaer/aria2.session
# 在Aria2退出时保存错误的、未完成的下载任务到会话文件
save-session=/home/Ariaer/aria2.session
# 定时保存会话, 0为退出时才保存, 需1.16.1以上版本, 默认:0
save-session-interval=60
## RPC相关设置 ##
# 启用RPC, 默认:false
enable-rpc=true
# 允许所有来源, 默认:false
rpc-allow-origin-all=true
# 允许外部访问, 默认:false
rpc-listen-all=true
# RPC端口, 仅当默认端口被占用时修改
# rpc-listen-port=6800
# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项
#rpc-secret=<TOKEN>
# 启动SSL
# rpc-secure=true
# 证书文件, 如果启用SSL则需要配置证书文件, 例如用https连接aria2
# rpc-certificate=
# rpc-private-key=
## BT/PT下载相关 ##
# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true
#follow-torrent=true
# 客户端伪装, PT需要
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
# 强制保存会话, 即使任务已经完成, 默认:false
# 较新的版本开启后会在任务完成后依然保留.aria2文件
#force-save=false
# 继续之前的BT任务时, 无需再次校验, 默认:false
bt-seed-unverified=true
# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false
bt-save-metadata=true
# 单个种子最大连接数, 默认:55 0表示不限制
bt-max-peers=0
# 最小做种时间, 单位:分
# seed-time = 60
# 分离做种任务
bt-detach-seed-only=true
4、运行aria2
aria2c --conf-path=/home/Ariaer/aria2.conf #选择配置文件的路径即可
5、打开浏览器,输入xxx.xxx.xxx.xxx/aria-ng
6、设置为systemctl服务,我单独创建一个用户了的,并且设置为/sbin/nologin。可以不按照我这样做,直接用root跑。
注意,要注释掉aria2配置文件里的daemon=true,即使默认不后台运行
cat << EOF > /usr/lib/systemd/system/aria2.service
[Unit]
Description=aria2
After=aria2.service
[Service]
#Type=forking
#PIDFile=/run/aria2.pid
ExecStart=/bin/sudo -u Ariaer /usr/bin/aria2c --conf-path=/home/Ariaer/aria2.conf
#ExecStart=/usr/bin/aria2c --conf-path=/home/Ariaer/aria2.conf
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable aria2.service
systemctl start aria2.service
参考
https://aria2.github.io/manual/en/html/README.html#how-to-build
http://www.senra.me/compile-aria2-for-centos6/comment-page-1/
https://github.com/aria2/aria2/releases
ssl/tls handshake fail
https://www.v2ex.com/amp/t/386081
https://my.oschina.net/u/4399743/blog/4244297
配置参考