CentOS7 简单搭建Aria2下载服务器
in Linux with 0 comment
CentOS7 简单搭建Aria2下载服务器
in Linux with 0 comment

安装开发者工具包


yum groupinstall "Development Tools"
yum -y install sqlite-devel gnutls-devel openssl-devel libssh2-devel c-ares-devel cppunit-devel libxml2-devel

获取源码并编译


wget https://github.com/aria2/aria2/releases/download/release-1.34.0/aria2-1.34.0.tar.xz && tar -Jxvf aria2-1.34.0.tar.xz && cd aria2
autoreconf -i

开启512线程支持

sed -i "s/\"1\", 1, 16,/\"1\", 1, 512,/g" src/OptionHandlerFactory.cc

静态编译编译


./configure --prefix=/usr/local --enable-static --enable-libaria2 ARIA2_STATIC=yes  --without-gnutls --with-openssl
make
make install

编译中遇到的坑:

报错:

/usr/bin/ld: cannot find -ltspi
collect2: error: ld returned 1 exit status
make[3]: *** [aria2c] Error 1
make[3]: Leaving directory `/root/aria2-1.34.0/src’
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/root/aria2-1.34.0/src’
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/aria2-1.34.0′
make: *** [all] Error 2

解决方法:

yum -y install trousers-devel

添加配置文件



## 文件保存相关 ##

# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置
dir=~/home/Data/Downloads/Aria2
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
disk-cache=32M
# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc
# 预分配所需时间: none < falloc ? trunc < prealloc
# falloc和trunc则需要文件系统和内核支持
# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项
file-allocation=trunc
# 断点续传
continue=true

## 下载连接相关 ##

# 最大同时下载任务数, 运行时可修改, 默认:5
max-concurrent-downloads=10
# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=16
# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M
# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载
min-split-size=10M
# 单个任务最大线程数, 添加时可指定, 默认:5
split=128
# 整体下载速度限制, 运行时可修改, 默认: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
# 连接超时时间, 默认:60
timeout=60
# 最大重试次数, 设置为0表示不限制重试次数, 默认:5
max-tries=0
# 设置重试等待的秒数, 默认:0
retry-wait=0

## 进度保存相关 ##

# 从会话文件中读取下载任务
input-file=/tmp/aria2.session
# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件
save-session=/tmp/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
# 事件轮询方式, 取值:[epoll, kqueue, port, poll, select], 不同系统默认值不同
#event-poll=select
# RPC监听端口, 端口被占用时可以修改, 默认:6800
rpc-listen-port=6800
# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项
#rpc-secret=<TOKEN>
# 设置的RPC访问用户名, 此选项新版已废弃, 建议改用 --rpc-secret 选项
#rpc-user=<USER>
# 设置的RPC访问密码, 此选项新版已废弃, 建议改用 --rpc-secret 选项
#rpc-passwd=<PASSWD>
# 是否启用 RPC 服务的 SSL/TLS 加密,
# 启用加密后 RPC 服务需要使用 https 或者 wss 协议连接
#rpc-secure=true
# 在 RPC 服务中启用 SSL/TLS 加密时的证书文件,
# 使用 PEM 格式时,您必须通过 --rpc-private-key 指定私钥
#rpc-certificate=/path/to/certificate.pem
# 在 RPC 服务中启用 SSL/TLS 加密时的私钥文件
#rpc-private-key=/path/to/certificate.key

## BT/PT下载相关 ##

# 当下载的是一个种子(以.torrent结尾)时, 自动开始BT任务, 默认:true
follow-torrent=true
# BT监听端口, 当端口被屏蔽时使用, 默认:6881-6999
listen-port=51413
# 单个种子最大连接数, 默认:55
bt-max-peers=55
# 打开DHT功能, PT需要禁用, 默认:true
enable-dht=false
# 打开IPv6 DHT功能, PT需要禁用
enable-dht6=false
# DHT网络监听端口, 默认:6881-6999
dht-listen-port=6881-6999
# 本地节点查找, PT需要禁用, 默认:false
bt-enable-lpd=false
# 种子交换, PT需要禁用, 默认:true
enable-peer-exchange=false
# 每个种子限速, 对少种的PT很有用, 默认:50K
#bt-request-peer-speed-limit=50K
bt-tracker=udp://tracker.coppersurfer.tk:6969/announce,udp://tracker.opentrackr.org:1337/announce,http://tracker.opentrackr.org:1337/announce,udp://p4p.arenabg.ch:1337/announce,udp://9.rarbg.to:2710/announce,udp://9.rarbg.me:2710/announce,udp://exodus.desync.com:6969/announce,udp://tracker.cyberia.is:6969/announce,udp://tracker.tiny-vps.com:6969/announce,udp://retracker.lanta-net.ru:2710/announce,udp://open.stealth.si:80/announce,udp://tracker3.itzmx.com:6961/announce,udp://tracker.torrent.eu.org:451/announce,http://tracker3.itzmx.com:6961/announce,http://tracker1.itzmx.com:8080/announce,udp://tracker.moeking.me:6969/announce,udp://ipv4.tracker.harry.lu:80/announce,udp://bt2.archive.org:6969/announce,udp://bt1.archive.org:6969/announce,udp://valakas.rollo.dnsabr.com:2710/announce,udp://tracker-udp.gbitt.info:80/announce,udp://retracker.akado-ural.ru:80/announce,udp://opentor.org:2710/announce,udp://explodie.org:6969/announce,https://tracker.gbitt.info:443/announce,http://tracker.gbitt.info:80/announce,http://explodie.org:6969/announce,udp://zephir.monocul.us:6969/announce,udp://www.midea123.z-media.com.cn:6969/announce,udp://wassermann.online:6969/announce,udp://vibe.community:6969/announce,udp://ultra.zt.ua:6969/announce,udp://u.wwwww.wtf:1/announce,udp://tracker2.dler.org:80/announce,udp://tracker0.ufibox.com:6969/announce,udp://tracker.zum.bi:6969/announce,udp://tracker.zerobytes.xyz:1337/announce,udp://tracker.zemoj.com:6969/announce,udp://tracker.vulnix.sh:6969/announce,udp://tracker.v6speed.org:6969/announce,udp://tracker.uw0.xyz:6969/announce,udp://tracker.skyts.net:6969/announce,udp://tracker.skynetcloud.site:6969/announce,udp://tracker.shkinev.me:6969/announce,udp://tracker.publictracker.xyz:6969/announce,udp://tracker.lelux.fi:6969/announce,udp://tracker.kamigami.org:2710/announce,udp://tracker.fortu.io:6969/announce,udp://tracker.dyne.org:6969/announce,udp://tracker.ds.is:6969/announce,udp://tracker.dler.org:6969/announce,udp://tracker.blacksparrowmedia.net:6969/announce,udp://tracker.army:6969/announce,udp://teamspeak.value-wolf.org:6969/announce,udp://t3.leech.ie:1337/announce,udp://t2.leech.ie:1337/announce,udp://t1.leech.ie:1337/announce,udp://storage.groupees.com:6969/announce,udp://sd-161673.dedibox.fr:6969/announce,udp://rutorrent.frontline-mod.com:6969/announce,udp://retracker.sevstar.net:2710/announce,udp://retracker.netbynet.ru:2710/announce,udp://retracker.local.msn-net.ru:6969/announce,udp://qg.lorzl.gq:2710/announce,udp://publictracker.xyz:6969/announce,udp://public.publictracker.xyz:6969/announce,udp://public-tracker.zooki.xyz:6969/announce,udp://opentracker.i2p.rocks:6969/announce,udp://nagios.tks.sumy.ua:80/announce,udp://mts.tvbit.co:6969/announce,udp://movies.zsw.ca:6969/announce,udp://mail.realliferpg.de:6969/announce,udp://ln.mtahost.co:6969/announce,udp://line-net.ru:6969/announce,udp://koli.services:6969/announce,udp://kanal-4.de:6969/announce,udp://josueunhuit.com:6969/announce,udp://inferno.demonoid.is:3391/announce,udp://handrew.me:6969/announce,udp://git.vulnix.sh:6969/announce,udp://free-tracker.zooki.xyz:6969/announce,udp://forever-tracker.zooki.xyz:6969/announce,udp://fe.dealclub.de:6969/announce,udp://engplus.ru:6969/announce,udp://eliastre100.fr:6969/announce,udp://edu.uifr.ru:6969/announce,udp://drumkitx.com:6969/announce,udp://dpiui.reedlan.com:6969/announce,udp://discord.heihachi.pw:6969/announce,udp://daveking.com:6969/announce,udp://cutiegirl.ru:6969/announce,udp://code2chicken.nl:6969/announce,udp://chanchan.uchuu.co.uk:6969/announce,udp://cdn-2.gamecoast.org:6969/announce,udp://cdn-1.gamecoast.org:6969/announce,udp://bubu.mapfactor.com:6969/announce,udp://bms-hosxp.com:6969/announce,udp://blokas.io:6969/announce,udp://bitsparadise.info:6969/announce,udp://benouworldtrip.fr:6969/announce,udp://aruacfilmes.com.br:6969/announce,udp://api.bitumconference.ru:6969/announce,udp://adminion.n-blade.ru:6969/announce,udp://admin.videoenpoche.info:6969/announce,udp://adm.category5.tv:6969/announce,udp://aaa.army:8866/announce,udp://6ahddutb1ucc3cp.ru:6969/announce,udp://61626c.net:6969/announce,udp://47.ip-51-68-199.eu:6969/announce,https://w.wwwww.wtf:443/announce,https://trakx.herokuapp.com:443/announce,https://tracker.tamersunion.org:443/announce,https://tracker.sloppyta.co:443/announce,https://tracker.nitrix.me:443/announce,https://tracker.lelux.fi:443/announce,https://tracker.hama3.net:443/announce,https://aaa.army:8866/announce,https://1337.abcvg.info:443/announce,http://vps02.net.orel.ru:80/announce,http://vpn.flying-datacenter.de:6969/announce,http://trun.tom.ru:80/announce,http://tracker2.dler.org:80/announce,http://tracker.zum.bi:6969/announce,http://tracker.zerobytes.xyz:1337/announce,http://tracker.ygsub.com:6969/announce,http://tracker.sloppyta.co:80/announce,http://tracker.skyts.net:6969/announce,http://tracker.noobsubs.net:80/announce,http://tracker.lelux.fi:80/announce,http://tracker.kamigami.org:2710/announce,http://tracker.dler.org:6969/announce,http://tracker.anonwebz.xyz:8080/announce,http://t.overflow.biz:6969/announce,http://t.nyaatracker.com:80/announce,http://rt.tace.ru:80/announce,http://retracker.sevstar.net:2710/announce,http://pow7.com:80/announce,http://opentracker.i2p.rocks:6969/announce,http://open.acgnxtracker.com:80/announce,http://h4.trakx.nibba.trade:80/announce,http://bobbialbano.com:6969/announce,http://aaa.army:8866/announce,udp://tsundere.pw:6969/announce,udp://tracker6.dler.org:2710/announce,udp://tracker4.itzmx.com:2710/announce,udp://tracker2.itzmx.com:6961/announce,udp://tracker.kali.org:6969/announce,udp://tracker.filemail.com:6969/announce,udp://tr.cili001.com:8070/announce,udp://tr.bangumi.moe:6969/announce,udp://open.lolicon.eu:7777/announce,udp://ns389251.ovh.net:6969/announce,udp://ns-1.x-fins.com:6969/announce,udp://concen.org:6969/announce,udp://camera.lei001.com:6969/announce,udp://btt.royalquest.ru:2710/announce,udp://bt2.54new.com:8080/announce,udp://bt.firebit.org:2710/announce,udp://bioquantum.co.za:6969/announce,udp://bclearning.top:6969/announce,udp://anidex.moe:6969/announce,https://tracker.imgoingto.icu:443/announce,http://tracker4.itzmx.com:2710/announce,http://tracker2.itzmx.com:6961/announce,http://tracker.bt4g.com:2095/announce,http://t.acg.rip:6699/announce,http://ankeschwarz.net:6969/announce
# 客户端伪装, PT需要
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0
seed-ratio=1
# 强制保存会话, 即使任务已经完成, 默认:false
# 较新的版本开启后会在任务完成后依然保留.aria2文件
force-save=false
# BT校验相关, 默认:true
bt-hash-check-seed=false
# 继续之前的BT任务时, 无需再次校验, 默认:false
bt-seed-unverified=true
# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false
bt-save-metadata=true

启动并在后台运行Aria2


aria2c --conf-path=/etc/config/aria2.conf -D

添加自启服务


[Unit]
Description=aria2 service
After=network.target
[Service]
User=lonny
Groups=users
Type=simple
ExecStart=/usr/local/bin/aria2c --conf-path=/etc/config/aria2.conf
ExecReload=
ExecStop=/bin/kill -WINCH ${MAINPID}
[Install]
WantedBy=multi-user.target

保存以上内容为aria2.service/etc/systemd/system目录下,并添加执行权限

systemcatl daemon-reload # 重新启动系统服务
systemctl enable aria2.service # 开机自启ariac
systemctl start aria2 # 启动aria2c
systemctl status aria2 # 查看aria2c启动状态

防火墙配置:


aria2c的RPC侦听6800端口,想要用web界面管理下载任务,就得用RPC

firewall-cmd --zone=public --add-port=6800/tcp --permanent
firewall-cmd --reload

自动更新tracker

#!/bin/bash
sed -i '$d' /home/xxx/aria2/aria2.conf
echo -n 'bt-tracker=' >>/home/xxx/aria2/aria2.conf
for line in `curl https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt`
    do echo -n $line,>>/home/xxx/aria2/aria2.conf
done

推荐一个Aria2c的WEB界面,十分好用,使用这个得配置httpd

https://github.com/mayswind/AriaNg

下载成品:

wget https://github.com/mayswind/AriaNg/releases/download/0.2.0/aria-ng-0.2.0.zip
unzip aria2ng-0.2.0.zip -C /var/www/html

访问http://serverip

Just Enjoy!

The article has been posted for too long and comments have been automatically closed.