Aria2+AriaNG搭建的下载机,在文件下载后往往需要通过远程登陆服务器的方式实现文件的操作,往往不够方便。通过挂载至Nextcloud、OneDrive、Google Drive等形式访问文件又由于无777权限而无法实现文件的真正管理。因此我尝试基于Aria2+AriaNG搭建的下载机,开发了一个文件管理平台,实现了下载文件后的增删改查、在线浏览与分享等功能。
文件结构:
root
└── .aria2
├── aria2.conf
├── aria2.log
└── aria2.session
/www/wwwroot/your_domain
├── AriaNg全部文件
└── down
└── 文件管理
uname -a #查看系统版本信息
首先找到适合自己系统的最新版的Aria2静态文件:查看地址
如:x86-64 就应该下载x64版本,即64bit
wget https://github.com/q3aql/aria2-static-builds/releases/download/v1.34.0/aria2-1.34.0-linux-gnu-64bit-build1.tar.bz2
tar jxvf aria2-*.tar.bz2 && rm -rf aria2-*.tar.bz2 && cd aria2-*
make install
##如果安装的时候提示-bash: make: command not found错误,需要先运行命令:
Debian/Ubuntu系统:apt install make -y
CentOS系统:yum install make -y
这时候就安装好了,可使用aria2c -v查看版本信息。
/www/wwwroot/your_domain/down/data/User/admin/home/下载文件/
chmod -Rf 777 ./*
或者
chmod 777 /www/wwwroot/your_domain/down/data/User/admin/home/下载文件/*
修改默认权限:(umask)
[root@localhost tmp]# vim /etc/bashrc
[root@localhost tmp]# vim /etc/profile
两个文件的内容是一样的
搜索umask,找到如下代码,不算第一位的特殊权限
if [ $UID -gt 199 ] && [ "`id -gn`" = "`id -un`" ]; then
umask 0000 //表示uid大于等于199的默认umask值,表示普通用户
else
umask 0000 //表示uid小于199的默认umask值,表示root
fi
修改后需要重新读取一下/etc/bashrc或/etc/profile
[root@lewis ~]# source /etc/profile
[root@lewis ~]# source /etc/bashrc
mkdir /root/.aria2/
vi /root/.aria2/aria2.conf
dir= /www/wwwroot/your_domain/down/data/User/admin/home/下载文件/
#允许rpc
enable-rpc=true
#允许所有来源, web界面跨域权限需要
rpc-allow-origin-all=true
#允许非外部访问
rpc-listen-all=true
## '#'开头为注释内容, 选项都有相应的注释说明, 根据需要修改 ##
## 被注释的选项填写的是默认值, 建议在需要修改时再取消注释 ##
## 文件保存相关 ##
# 文件的保存路径(可使用绝对路径或相对路径)#################################此处需要修改
dir=
# 启用磁盘缓存, 0为禁用缓存, 需1.16以上版本, 默认:16M
#disk-cache=32M
# 文件预分配方式, 能有效降低磁盘碎片, 默认:prealloc
# 预分配所需时间: none < falloc ? trunc < prealloc
# falloc和trunc则需要文件系统和内核支持
# NTFS建议使用falloc, EXT3/4建议trunc, MAC 下需要注释此项
# file-allocation=none
# 断点续传
continue=true
## 下载连接相关 ##
# 最大同时下载任务数, 运行时可修改, 默认:5
max-concurrent-downloads=10
# 同一服务器连接数, 添加时可指定, 默认:1
max-connection-per-server=5
# 最小文件分片大小, 添加时可指定, 取值范围1M -1024M, 默认:20M
# 假定size=10M, 文件为20MiB 则使用两个来源下载; 文件为15MiB 则使用一个来源下载
min-split-size=10M
# 单个任务最大线程数, 添加时可指定, 默认:5
split=20
# 整体下载速度限制, 运行时可修改, 默认:0
#max-overall-download-limit=0
# 单个任务下载速度限制, 默认:0
#max-download-limit=0
# 整体上传速度限制, 运行时可修改, 默认:0
max-overall-upload-limit=1M
# 单个任务上传速度限制, 默认:0
#max-upload-limit=1000
# 禁用IPv6, 默认:false
disable-ipv6=false
## 进度保存相关 ##
# 从会话文件中读取下载任务
input-file=/root/.aria2/aria2.session
# 在Aria2退出时保存`错误/未完成`的下载任务到会话文件
save-session=/root/.aria2/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=
# 设置的RPC访问用户名, 此选项新版已废弃, 建议改用 --rpc-secret 选项
#rpc-user=
# 设置的RPC访问密码, 此选项新版已废弃, 建议改用 --rpc-secret 选项
#rpc-passwd=
# 是否启用 RPC 服务的 SSL/TLS 加密,
# 启用加密后 RPC 服务需要使用 https 或者 wss 协议连接
#rpc-secure=true
# 在 RPC 服务中启用 SSL/TLS 加密时的证书文件(.pem/.crt)
#rpc-certificate=/root/xxx.pem
# 在 RPC 服务中启用 SSL/TLS 加密时的私钥文件(.key)
#rpc-private-key=/root/xxx.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=true
# 打开IPv6 DHT功能, PT需要禁用
#enable-dht6=false
# DHT网络监听端口, 默认:6881-6999
#dht-listen-port=6881-6999
# 本地节点查找, PT需要禁用, 默认:false
#bt-enable-lpd=true
# 种子交换, PT需要禁用, 默认:true
enable-peer-exchange=true
# 每个种子限速, 对少种的PT很有用, 默认:50K
#bt-request-peer-speed-limit=50K
# 客户端伪装, PT需要
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
# 当种子的分享率达到这个数时, 自动停止做种, 0为一直做种, 默认:1.0
seed-ratio=0.1
# 强制保存会话, 即使任务已经完成, 默认:false
# 较新的版本开启后会在任务完成后依然保留.aria2文件
force-save=true
# BT校验相关, 默认:true
#bt-hash-check-seed=true
# 继续之前的BT任务时, 无需再次校验, 默认:false
bt-seed-unverified=true
# 保存磁力链接元数据为种子文件(.torrent文件), 默认:false
#bt-save-metadata=true
为Aria2添加session会话文件,日志文件,路径和配置文件里一致
touch /root/.aria2/aria2.session /root/.aria2/aria2.log
aria2c --conf-path=/root/.aria2/aria2.conf -D
aria2c /root/.aria2/aria2.conf -D # 2.0 版本以后的启动方式
#后台运行——注意 前者和这个命令要先后输入,不可选择性输入一个。
nohup aria2c --conf-path=/root/.aria2/aria2.conf > /root/.aria2/aria2.log 2>&1 &
切记需要放行端口!!!
如果前置权限没有设置在启动aria2后再行变更umask后需要重启aria2!!!
cd /www/wwwroot/95.169.4.225/ariaNg
wget http://dxj.im/aria-ng-020 && unzip aria-ng-0.2.0.zip
备用: wget https://www.moerats.com/usr/down/aria-ng-0.2.0.zip && unzip aria-ng-0.2.0.zip
<a href="http://domain/down">down<i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i></a>
附一份AriaNg index.html
完整版
<!DOCTYPE html><html ng-app="ariaNg" manifest="index.manifest"><head><meta charset="utf-8"><meta http-equiv="Content-Type" content="text/html;charset=utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no,minimal-ui" name="viewport"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-title" content="AriaNg"><meta name="apple-mobile-web-app-status-bar-style" content="black"><meta name="description" content="Aria2 Ng Frontend"><meta name="theme-color" content="#3c4852"><meta name="format-detection" content="telephone=no"><title>AriaNg</title><link rel="stylesheet" href="css/bootstrap-3.3.7.min.css"><link rel="stylesheet" href="css/plugins-a7090b9582.min.css"><link rel="stylesheet" href="css/aria-ng-089c039102.min.css"></head><body class="hold-transition skin-aria-ng sidebar-mini fixed"><div class="wrapper" ng-controller="MainController" ng-swipe-left="swipeActions.leftSwipe()" ng-swipe-right="swipeActions.rightSwipe()" ng-swipe-disable-mouse><header class="main-header"><div class="logo"><div class="logo-mini">AriaNg</div><div class="logo-lg" title="AriaNg v0.2.0"><div class="dropdown"><span class="dropdown-toggle" data-toggle="dropdown"><span class="logo-lg-title">AriaNg</span><span class="caret"></span></span><ul class="dropdown-menu dropdown-menu-right" role="menu"><li ng-repeat="setting in rpcSettings" ng-class="{'active': setting.isDefault}"><a class="pointer-cursor" ng-click="switchRpcSetting(setting)"><span ng-bind="(setting.rpcAlias ? setting.rpcAlias : setting.rpcHost + ':' + setting.rpcPort)">RPC</span> <i class="fa" ng-class="{'fa-check': setting.isDefault}"></i></a></li></ul></div></div></div><nav class="navbar navbar-static-top" role="navigation"><div class="navbar-toolbar"><ul class="nav navbar-nav"><li><a class="toolbar" title="{{'New' | translate}}" ng-href="#!/new"><i class="fa fa-plus"></i> <span translate>New</span></a></li><li class="divider"></li><li class="disabled" ng-class="{'disabled': !isSpecifiedTaskSelected('paused')}"><a class="toolbar" title="{{'Start' | translate}}" ng-click="changeTasksState('start')"><i class="fa fa-play"></i></a></li><li class="disabled" ng-class="{'disabled': !isSpecifiedTaskSelected('active', 'waiting')}"><a class="toolbar" title="{{'Pause' | translate}}" ng-click="changeTasksState('pause')"><i class="fa fa-pause"></i></a></li><li class="disabled" ng-class="{'disabled': !isTaskSelected() && !isSpecifiedTaskShowing('complete', 'error', 'removed')}"><a class="toolbar dropdown-toggle" data-toggle="dropdown" title="{{'Delete' | translate}}"><i class="fa fa-trash-o"></i> <i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i></a><ul class="dropdown-menu" role="menu"><li ng-if="isTaskSelected()"><a class="pointer-cursor" ng-click="removeTasks()"><span translate>Remove Task</span></a></li><li ng-if="taskContext.enableSelectAll && isSpecifiedTaskShowing('complete', 'error', 'removed')"><a class="pointer-cursor" ng-click="clearStoppedTasks()"><span translate>Clear Stopped Tasks</span></a></li></ul></li><li class="divider"></li><li class="disabled" ng-class="{'disabled': !taskContext.enableSelectAll || !taskContext.list || taskContext.list.length < 1}"><a class="toolbar" title="{{'Select All' | translate}}" ng-click="selectAllTasks()"><i class="fa fa-th-large"></i></a></li><li class="disabled" ng-class="{'disabled': !taskContext.enableSelectAll || !taskContext.list || taskContext.list.length < 1}"><a class="toolbar dropdown-toggle" data-toggle="dropdown" title="{{'Display Order' | translate}}"><i class="fa fa-sort-alpha-asc"></i> <i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i></a><ul class="dropdown-menu" role="menu"><li><a class="pointer-cursor" ng-click="changeDisplayOrder('default:asc')"><span translate>Default</span> <i class="fa" ng-class="{'fa-check': isSetDisplayOrder('default')}"></i></a></li><li><a class="pointer-cursor" ng-click="changeDisplayOrder('name:asc')"><span translate>By File Name</span> <i class="fa" ng-class="{'fa-check': isSetDisplayOrder('name')}"></i></a></li><li><a class="pointer-cursor" ng-click="changeDisplayOrder('size:asc')"><span translate>By File Size</span> <i class="fa" ng-class="{'fa-check': isSetDisplayOrder('size')}"></i></a></li><li><a class="pointer-cursor" ng-click="changeDisplayOrder('percent:desc')"><span translate>By Progress</span> <i class="fa" ng-class="{'fa-check': isSetDisplayOrder('percent')}"></i></a></li><li><a class="pointer-cursor" ng-click="changeDisplayOrder('remain:asc')"><span translate>By Remain Time</span> <i class="fa" ng-class="{'fa-check': isSetDisplayOrder('remain')}"></i></a></li><li><a class="pointer-cursor" ng-click="changeDisplayOrder('dspeed:desc')"><span translate>By Download Speed</span> <i class="fa" ng-class="{'fa-check': isSetDisplayOrder('dspeed')}"></i></a></li><li><a class="pointer-cursor" ng-click="changeDisplayOrder('uspeed:desc')"><span translate>By Upload Speed</span> <i class="fa" ng-class="{'fa-check': isSetDisplayOrder('uspeed')}"></i></a></li></ul></li><li class="divider"></li><li><a class="toolbar" title="{{'Help' | translate}}" href="http://github.com/mayswind/AriaNg" target="_blank"><i class="fa fa-question-circle-o"></i></a></li></ul></div><div class="navbar-searchbar hidden-xs"><ul class="nav navbar-nav"><li><input class="form-control" ng-placeholder="('Search' | translate)" title="{{'Search' | translate}}" ng-model="searchContext.text"><div class="form-control-icon"><span class="fa fa-search form-control-feedback"></span></div></li></ul></div></nav></header><aside class="main-sidebar"><section class="sidebar"><ul id="siderbar-menu" class="sidebar-menu"><li class="header" translate>Download</li><li data-href-match="/downloading"><a href="#!/downloading"><i class="fa fa-arrow-circle-o-down"></i> <span ng-bind="('Downloading' | translate) + (globalStat && globalStat.numActive > 0 ? ' (' + globalStat.numActive + ')' : '')">Downloading</span></a></li><li data-href-match="/waiting"><a href="#!/waiting"><i class="fa fa-clock-o"></i> <span ng-bind="('Waiting' | translate) + (globalStat && globalStat.numWaiting > 0 ? ' (' + globalStat.numWaiting + ')' : '')">Waiting</span></a></li><li data-href-match="/stopped"><a href="#!/stopped"><i class="fa fa-check-circle-o"></i> <span ng-bind="('Finished / Stopped' | translate) + (globalStat && globalStat.numStopped > 0 ? ' (' + globalStat.numStopped + ')' : '')">Finished / Stopped</span></a></li><li class="header" translate>Settings</li><li data-href-match="/settings/ariang"><a href="#!/settings/ariang"><i class="fa fa-cog"></i> <span translate>AriaNg Settings</span></a></li><li class="treeview"><a href="javascript:void(0);"><i class="fa fa-cogs"></i> <span translate>Aria2 Settings</span> <span class="pull-right-container"><i class="fa fa-angle-left pull-right"></i></span></a><ul class="treeview-menu"><li data-href-match="/settings/aria2/basic"><a href="#!/settings/aria2/basic"><span translate>Basic Settings</span></a></li><li data-href-match="/settings/aria2/http-ftp-sftp"><a href="#!/settings/aria2/http-ftp-sftp"><span translate>HTTP/FTP/SFTP Settings</span></a></li><li data-href-match="/settings/aria2/http"><a href="#!/settings/aria2/http"><span translate>HTTP Settings</span></a></li><li data-href-match="/settings/aria2/ftp-sftp"><a href="#!/settings/aria2/ftp-sftp"><span translate>FTP/SFTP Settings</span></a></li><li data-href-match="/settings/aria2/bt"><a href="#!/settings/aria2/bt"><span translate>BitTorrent Settings</span></a></li><li data-href-match="/settings/aria2/metalink"><a href="#!/settings/aria2/metalink"><span translate>Metalink Settings</span></a></li><li data-href-match="/settings/aria2/rpc"><a href="#!/settings/aria2/rpc"><span translate>RPC Settings</span></a></li><li data-href-match="/settings/aria2/advanced"><a href="#!/settings/aria2/advanced"><span translate>Advanced Settings</span></a></li></ul></li><li data-href-match="/status"><a href="#!/status"><i class="fa fa-server"></i> <span translate>Aria2 Status</span> <span class="label pull-right" ng-if="globalStatusContext.isEnabled" ng-class="{'label-primary': taskContext.rpcStatus === 'Connecting', 'label-success': taskContext.rpcStatus === 'Connected', 'label-danger': taskContext.rpcStatus === 'Not Connected'}" ng-bind="taskContext.rpcStatus | translate"></span></a></li></ul></section></aside><div id="content-wrapper" class="content-wrapper"><div id="content-body" class="content-body"><div ng-view cg-busy="{ promise: loadPromise, message: ('Loading' | translate) }"></div></div></div><footer class="main-footer"><nav class="navbar" role="navigation"><div class="navbar-toolbar"><ul class="nav navbar-nav"><li><a data-toggle="offcanvas" role="button" title="{{'Toggle Navigation' | translate}}"><i class="fa fa-bars"></i></a></li><li class="divider"></li><li class="dropup"><a class="dropdown-toggle" data-toggle="dropdown" role="button" title="{{'Quick Setting' | translate}}"><i class="fa fa-wrench"></i> <span translate>Quick Setting</span> <i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i></a><ul class="dropdown-menu" role="menu"><li><a class="pointer-cursor" ng-click="showQuickSettingDialog('globalSpeedLimit', 'Global Speed Limit')"><span translate>Global Speed Limit</span></a></li></ul></li><li class="divider"></li><li><a role="button" title="down" href="http://your_domain/down" target="_blank"><i class="fa fa-server"></i><span class="ng-scope"> down</span> <i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i></a><li class="divider"></li><li class="dropup"><a class="dropdown-toggle" data-toggle="dropdown" role="button" title="站点"><i class="fa fa-link"></i> <span translate="">站点</span> <i class="fa fa-caret-right fa-right-bottom fa-rotate-45 fa-half" aria-hidden="true"></i></a><ul class="dropdown-menu" role="menu"><li><a class="pointer-cursor" href="http://zuidazy.net/" target="_blank" ">">最大资源站(推荐)- cursor" href="http://music.junyuewl.com/" target="_blank" "><span translate="">音乐下载</span></a></li><li><a class="pointer-cursor" href="http://www.yongjiuzy.cc/" target="_blank" ">">永久资源站