Fork me on GitHub

Aria2&AriaNG、OneIndex 配置

Aria2 介绍

aria2 is a lightweight multi-protocol & multi-source command-line download utility. It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink. aria2 can be manipulated via built-in JSON-RPC and XML-RPC interfaces. (from https://aria2.github.io)

安装 Aria2

下载脚本并运行

1
wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh

运行脚本后会出现以下菜单选项:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 Aria2 一键安装管理脚本 [v1.1.9]
-- Toyo | doub.io/shell-jc4 --

0. 升级脚本
————————————
1. 安装 Aria2
2. 更新 Aria2
3. 卸载 Aria2
————————————
4. 启动 Aria2
5. 停止 Aria2
6. 重启 Aria2
————————————
7. 修改 配置文件
8. 查看 配置信息
9. 查看 日志信息
10. 配置 自动更新 BT-Tracker服务器
————————————

当前状态: 已安装 并 已启动

请输入数字 [0-10]:

按提示操作即可。
PS:
启动: /etc/init.d/aria2 start
停止: /etc/init.d/aria2 stop
当前状态: /etc/init.d/aria2 status
配置文件路径: /root/.aria2/aria2.conf
令牌密钥: 随机生成,可以更改
下载目录:/usr/local/caddy/www/aria2/Download
来源:逗比教程


安装 AriaNG

由于 Aria2 是一个命令行下载工具,每次使用敲命令下载文件不方便,有大佬开发出的开源 WEB 面板来管理下载任务。其中之一便是 AriaNG
AriaNG 只是一个 WEB 端的管理面板,可以远程连接 Aria2,二者可以分处不同服务器。

直接从 GitHub 项目主页下载解压到服务器即可,此时即可通过 IP 或配置好的域名进行访问。
具体效果可访问 http://aria2.tryme.wang查看


安装 OneIndex

可以使用宝塔面板新建网站,全程 WEB 面板操作,简单粗暴。安装参考:宝塔
OneIndex 项目主页:https://github.com/donwa/oneindex
image
下载:

1
git clone https://github.com/donwa/oneindex.git

移动到网站根目录后要分配权限:

1
chmod 777 ./config && chmod 777 ./cache

此时根据配置的域名,访问 http://xxx.com/?/admin,默认的密码是 oneindex,按照提示配置即可。
PS:可以配置 Nginx 伪静态去掉管理页面 URL 中的“?”,伪静态配置如下:

1
2
3
if (!-e $request_filename) {
rewrite / /?/ last;
}


配置 Aria2 下载后自动上传

新建一个脚本文件:

1
vi /root/.aria2/oneindexup.sh

复制以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
path=$3 #取原始路径,我的环境下如果是单文件则为/data/demo.png,如果是文件夹则该值为文件夹内某个文件比如/data/a/b/c/d.jpg
downloadpath='/usr/local/caddy/www/aria2/Download' #修改成Aria2下载文件夹
domain='tryme.wang' #修改成自己域名

if [ $2 -eq 0 ]
then
exit 0
fi
while true; do #提取下载文件根路径,如把/data/a/b/c/d.jpg变成/data/a
filepath=$path
path=${path%/*};
if [ "$path" = "$downloadpath" ] && [ $2 -eq 1 ] #如果下载的是单个文件
then
php /www/wwwroot/$domain/one.php upload:file $filepath /$folder/
rm -rf $filepath
php /www/wwwroot/$domain/one.php cache:refresh
exit 0
elif [ "$path" = "$downloadpath" ]
then
php /www/wwwroot/$domain/one.php upload:folder $filepath /$folder/
rm -rf "$filepath/"
php /www/wwwroot/$domain/one.php cache:refresh
exit 0
fi
done

给脚本分配可执行权限:

1
chmod +x /root/.aria2/oneindexup.sh

最后写入配置文件,即上面安装 Aria2 时的配置文件 /root/.aria2/aria2.conf
编辑配置文件或者直接命令:

1
echo "on-download-complete=/root/.aria2/oneindexup.sh" >>/root/.aria2/aria2.conf

参考自:Rat‘s大佬

------本文结束------
0%