什么是 aria2
aria2 是一个轻量级的多协议和多源命令行下载工具。它支持 HTTP/HTTPS,FTP,SFTP,BitTorrent 和 Metalink。aria2 可以通过内置的 JSON-RPC 和 XML-RPC 接口进行操作。
配置 aria2(RPC 模式)
-
下载和安装
以下两种安装方式任选一种即可:
-
从 aria2/aria2 - GitHub 下载
.dmg
格式安装程序,双击安装 -
使用 Homebrew
brew install aria2 复制代码
-
-
配置
配置文件也可放在其他目录下,但是将其放在用户根目录下可省去启动时指定配置文件位置的麻烦 [1]。依次执行如下操作:
-
在用户根目录,即
/Users/<username>
目录下新建 ** 隐藏 ** 文件夹.aria2
,并在其中新建aria2.conf
文件mkdir ~/.aria2 cd .aria2 touch aria2.conf 复制代码
-
打开 Finder,找到
~/.aria2/aria2.conf
(可使用Shift+Command+G
转到路径或使用Shift+Command+.
显示隐藏文件),双击打开,编辑并保存自己的配置。以下为 雪月秋水君 提供的一个参考配置 [2]#用户名 #rpc-user=user #密码 #rpc-passwd=passwd #上面的认证方式不建议使用,建议使用下面的 token 方式 #设置加密的密钥 #rpc-secret=token #允许 RPC enable-rpc=true #允许所有来源,Web 界面跨域权限需要 rpc-allow-origin-all=true #允许外部访问,false 的话只监听本地端口 rpc-listen-all=true #RPC 端口,仅当默认端口被占用时修改 #rpc-listen-port=6800 #最大同时下载数(任务数),路由建议值:3 max-concurrent-downloads=5 #断点续传 continue=true #同服务器连接数 max-connection-per-server=5 #最小文件分片大小,下载线程数上限取决于能分出多少片,对于小文件重要 min-split-size=10M #单文件最大线程数,路由建议值:5 split=10 #下载速度限制 max-overall-download-limit=0 #单文件速度限制 max-download-limit=0 #上传速度限制 max-overall-upload-limit=0 #单文件速度限制 max-upload-limit=0 #断开速度过慢的连接 #lowest-speed-limit=0 #验证用,需要 1.16.1 之后的 release 版本 #referer=* #文件保存路径,默认为当前启动位置 dir=/Users/<username>/Downloads #文件缓存,使用内置的文件缓存,如果你不相信 Linux 内核文件缓存和磁盘内置缓存时使用,需要 1.16 及以上版本 #disk-cache=0 #另一种 Linux 文件缓存方式,使用前确保您使用的内核支持此选项,需要 1.15 及以上版本 #enable-mmap=true #文件预分配,能有效降低文件碎片,提高磁盘性能,缺点是预分配时间较长 #所需时间 none<falloc?trunc«prealloc,falloc 和 trunc 需要文件系统和内核支持 file-allocation=prealloc 复制代码
-
启动
aria2c
aria2c -conf-path="/Users/<username>/.aria2/aria.conf" -D 复制代码
-
配置开机自启
-
打开 Automator,新建一个 Application
-
在左侧 Library 中找到或搜索
RunShellScript
,拖拽添加至右侧。点击 Options,勾选 Ignore this action's input -
输入
/usr/local/aria2/bin/aria2c —conf-path="/Users/<username>/.aria2/aria.conf" -D 复制代码
保存并退出
-
打开 System Perferences - Users & Groups - Login Items,添加刚才制作的 Application,勾选 Hide 即可