Total Pageviews

Sunday, 20 September 2026

强大的下载工具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.

Download

Download version 1.37.0. There you can download source distribution and binaries for OS X, Windows and Android.

The legacy releases earlier than 1.19.1 are available here.

Features

  • Multi-Connection Download. aria2 can download a file from multiple sources/protocols and tries to utilize your maximum download bandwidth. Really speeds up your download experience.

  • Lightweight. aria2 doesn’t require much memory and CPU time. When disk cache is off, the physical memory usage is typically 4MiB (normal HTTP/FTP downloads) to 9MiB (BitTorrent downloads). CPU usage in BitTorrent with download speed of 2.8MiB/sec is around 6%.

  • Fully Featured BitTorrent Client. All features you want in BitTorrent client are available: DHT, PEX, Encryption, Magnet URI, Web-Seeding, Selective Downloads, Local Peer Discovery and UDP tracker.

  • Metalink Enabled. aria2 supports The Metalink Download Description Format (aka Metalink v4), Metalink version 3 and Metalink/HTTP. Metalink offers the file verification, HTTP/FTP/SFTP/BitTorrent integration and the various configurations for language, location, OS, etc.

  • Remote Control. aria2 supports RPC interface to control the aria2 process. The supported interfaces are JSON-RPC (over HTTP and WebSocket) and XML-RPC.

Usage Examples

Command-line scares you off? No, aria2 is really easy to use!!

Download from WEB:

1
$ aria2c http://example.org/mylinux.iso

Download from 2 sources:

1
$ aria2c http://a/f.iso ftp://b/f.iso

Download using 2 connections per host:

1
$ aria2c -x2 http://a/f.iso

BitTorrent:

1
$ aria2c http://example.org/mylinux.torrent

BitTorrent Magnet URI:

1
$ aria2c 'magnet:?xt=urn:btih:248D0A1CD08284299DE78D5C1ED359BB46717D8C'

Metalink:

1
$ aria2c http://example.org/mylinux.metalink

Download URIs found in text file:

1
$ aria2c -i uris.txt

Related Projects

  • apt-metalink: Faster package downloads for Debian/Ubuntu
  • powerpill: Pacman wrapper for parallel and segmented downloads.
  • python3-aria2jsonrpc: A wrapper class around Aria2’s JSON RPC interface.
  • aria2.js: JavaScript (browsers and Node.js) library and cli for aria2 RPC

UI Frontends

  • webui-aria2: Web browser interface for aria2 (2012 GSOC project)
  • uGet: the Linux Download Manager

from  https://aria2.github.io/

( https://aria2.github.io/manual/en/html/)

下载地址: https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip

------------------------------------

 aria2 is a lightweight multi-protocol & multi-source, cross platform download utility operated in command-line. It supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink.

 

aria2 can download a file from multiple sources/protocols and tries to utilize your maximum download bandwidth. It supports downloading a file from HTTP(S)/FTP/SFTP and BitTorrent at the same time, while the data downloaded from HTTP(S)/FTP/SFTP is uploaded to the BitTorrent swarm. Using Metalink's chunk checksums, aria2 automatically validates chunks of data while downloading a file like BitTorrent.

The project page is located at https://aria2.github.io/.

See the aria2 Online Manual (Russian translation, Portuguese translation) to learn how to use aria2.

Features

Here is a list of features:

  • Command-line interface
  • Download files through HTTP(S)/FTP/SFTP/BitTorrent
  • Segmented downloading
  • Metalink version 4 (RFC 5854) support(HTTP/FTP/SFTP/BitTorrent)
  • Metalink version 3.0 support(HTTP/FTP/SFTP/BitTorrent)
  • Metalink/HTTP (RFC 6249) support
  • HTTP/1.1 implementation
  • HTTP Proxy support
  • HTTP BASIC authentication support
  • HTTP Proxy authentication support
  • Well-known environment variables for proxy: http_proxy, https_proxy, ftp_proxy, all_proxy and no_proxy
  • HTTP gzip, deflate content encoding support
  • Verify peer using given trusted CA certificate in HTTPS
  • Client certificate authentication in HTTPS
  • Chunked transfer encoding support
  • Load Cookies from the file using the Firefox3 format, Chromium/Google Chrome and the Mozilla/Firefox (1.x/2.x)/Netscape format.
  • Save Cookies in the Mozilla/Firefox (1.x/2.x)/Netscape format.
  • Custom HTTP Header support
  • Persistent Connections support
  • FTP/SFTP through HTTP Proxy
  • Download/Upload speed throttling
  • BitTorrent extensions: Fast extension, DHT, PEX, MSE/PSE, Multi-Tracker, UDP tracker
  • BitTorrent WEB-Seeding. aria2 requests chunk more than piece size to reduce the request overhead. It also supports pipelined requests with piece size.
  • BitTorrent Local Peer Discovery
  • Rename/change the directory structure of BitTorrent downloads completely
  • JSON-RPC (over HTTP and WebSocket)/XML-RPC interface
  • Run as a daemon process
  • Selective download in multi-file torrent/Metalink
  • Chunk checksum validation in Metalink
  • Can disable segmented downloading in Metalink
  • Netrc support
  • Configuration file support
  • Download URIs found in a text file or stdin and the destination directory and output file name can be specified optionally
  • Parameterized URI support
  • IPv6 support with Happy Eyeballs
  • Disk cache to reduce disk activity

 

How to get source code

We maintain the source code at Github: https://github.com/aria2/aria2

To get the latest source code, run the following command:

$ git clone https://github.com/aria2/aria2.git

This will create an aria2 directory in your current directory and source files are stored there.

Dependency

features dependency
HTTPS OSX or GnuTLS or OpenSSL or Windows
SFTP libssh2
BitTorrent None. Optional: libnettle+libgmp or libgcrypt or OpenSSL (see note)
Metalink libxml2 or Expat.
Checksum None. Optional: OSX or libnettle or libgcrypt or OpenSSL or Windows (see note)
gzip, deflate in HTTP zlib
Async DNS C-Ares
Firefox3/Chromium cookie libsqlite3
XML-RPC libxml2 or Expat.
JSON-RPC over WebSocket libnettle or libgcrypt or OpenSSL

Note

libxml2 has precedence over Expat if both libraries are installed. If you prefer Expat, run configure with --without-libxml2.

Note

On Apple OSX, OS-level SSL/TLS support will be preferred. Hence neither GnuTLS nor OpenSSL is required on that platform. If you'd like to disable this behavior, run configure with --without-appletls.

GnuTLS has precedence over OpenSSL if both libraries are installed. If you prefer OpenSSL, run configure with --without-gnutls --with-openssl.

On Windows, there is SSL implementation available that is based on the native Windows SSL capabilities (Schannel) and it will be preferred. Hence neither GnuTLS nor OpenSSL is required on that platform. If you'd like to disable this behavior, run configure with --without-wintls.

Note

On Apple OSX, the OS-level checksum support will be preferred, unless aria2 is configured with --without-appletls.

libnettle has precedence over libgcrypt if both libraries are installed. If you prefer libgcrypt, run configure with --without-libnettle --with-libgcrypt. If OpenSSL is selected over GnuTLS, neither libnettle nor libgcrypt will be used.

If none of the optional dependencies are installed, an internal implementation that only supports md5 and sha1 will be used.

On Windows, there is SSL implementation available that is based on the native Windows capabilities and it will be preferred, unless aria2 is configured with --without-wintls.

A user can have one of the following configurations for SSL and crypto libraries:

  • OpenSSL
  • GnuTLS + libgcrypt
  • GnuTLS + libnettle
  • Apple TLS (OSX only)
  • Windows TLS (Windows only)

You can disable BitTorrent and Metalink support by providing --disable-bittorrent and --disable-metalink to the configure script respectively.

To enable async DNS support, you need c-ares.

How to build

aria2 is primarily written in C++. Initially, it was written based on C++98/C++03 standard features. We are now migrating aria2 to the C++11 standard. The current source code requires a C++11 aware compiler. For well-known compilers, such as g++ and clang, the -std=c++11 or -std=c++0x flag must be supported.

To build aria2 from the source package, you need the following development packages (package name may vary depending on the distribution you use):

  • libgnutls-dev (Required for HTTPS, BitTorrent, Checksum support)
  • nettle-dev (Required for BitTorrent, Checksum support)
  • libgmp-dev (Required for BitTorrent)
  • libssh2-1-dev (Required for SFTP support)
  • libc-ares-dev (Required for async DNS support)
  • libxml2-dev (Required for Metalink support)
  • zlib1g-dev (Required for gzip, deflate decoding support in HTTP)
  • libsqlite3-dev (Required for Firefox3/Chromium cookie support)
  • pkg-config (Required to detect installed libraries)

You can use libgcrypt-dev instead of nettle-dev and libgmp-dev:

  • libgpg-error-dev (Required for BitTorrent, Checksum support)
  • libgcrypt-dev (Required for BitTorrent, Checksum support)

You can use libssl-dev instead of libgnutls-dev, nettle-dev, libgmp-dev, libgpg-error-dev and libgcrypt-dev:

  • libssl-dev (Required for HTTPS, BitTorrent, Checksum support)

You can use libexpat1-dev instead of libxml2-dev:

  • libexpat1-dev (Required for Metalink support)

On Fedora you need the following packages: gcc, gcc-c++, kernel-devel, libgcrypt-devel, libxml2-devel, openssl-devel, gettext-devel, cppunit

If you downloaded source code from a git repository, you have to install the following packages to get autoconf macros:

  • libxml2-dev
  • libcppunit-dev
  • autoconf
  • automake
  • autotools-dev
  • autopoint
  • libtool

And run the following command to generate configure script and other files necessary to build the program:

$ autoreconf -i

Also, you need Sphinx to build the man page.

If you are building aria2 for Mac OS X, take a look at the makerelease-osx.mk GNU Make makefile.

The quickest way to build aria2 is first to run configure script:

$ ./configure

To build statically linked aria2, use ARIA2_STATIC=yes command-line option:

$ ./configure ARIA2_STATIC=yes

After configuration is done, run make to compile the program:

$ make

See Cross-compiling Windows binary to create a Windows binary. See Cross-compiling Android binary to create an Android binary.

The configure script checks available libraries and enables as many features as possible except for experimental features not enabled by default.

Since 1.1.0, aria2 checks the certificate of HTTPS servers by default. If you build with OpenSSL or the recent version of GnuTLS which has gnutls_certificate_set_x509_system_trust() function and the library is properly configured to locate the system-wide CA certificates store, aria2 will automatically load those certificates at the startup. If it is not the case, I recommend supplying the path to the CA bundle file. For example, in Debian the path to CA bundle file is '/etc/ssl/certs/ca-certificates.crt' (in ca-certificates package). This may vary depending on your distribution. You can give it to configure script using --with-ca-bundle option:

$ ./configure --with-ca-bundle='/etc/ssl/certs/ca-certificates.crt'
$ make

Without --with-ca-bundle option, you will encounter the error when accessing HTTPS servers because the certificate cannot be verified without the CA bundle. In such a case, you can specify the CA bundle file using aria2's --ca-certificate option. If you don't have the CA bundle file installed, then the last resort is to disable the certificate validation using --check-certificate=false.

Using the native OSX (AppleTLS) and/or Windows (WinTLS) implementation will automatically use the system certificate store, so --with-ca-bundle is not necessary and will be ignored when using these implementations.

By default, the bash_completion file named aria2c is installed to the directory $prefix/share/doc/aria2/bash_completion. To change the install directory of the file, use --with-bashcompletiondir option.

After a make, the executable is located at src/aria2c.

aria2 uses CppUnit for automated unit testing. To run the unit test:

$ make check

Cross-compiling Windows binary

In this section, we describe how to build a Windows binary using a mingw-w64 (http://mingw-w64.org/doku.php) cross-compiler on Debian Linux. The MinGW (http://www.mingw.org/) may not be able to build aria2.

The easiest way to build Windows binary is using Dockerfile.mingw. See Dockerfile.mingw how to build a binary. If you cannot use Dockerfile, then continue to read the following paragraphs.

Basically, after compiling and installing depended libraries, you can do cross-compile just passing appropriate --host option and specifying CPPFLAGS, LDFLAGS, and PKG_CONFIG_LIBDIR variables to configure. For convenience and to lower our own development cost, we provide an easier way to configure the build settings.

mingw-config script is a configure script wrapper for mingw-w64. We use it to create official Windows build. This script assumes the following libraries have been built for cross-compile:

  • c-ares
  • expat
  • sqlite3
  • zlib
  • libssh2
  • cppunit

Some environment variables can be adjusted to change build settings:

HOST
cross-compile to build programs to run on HOST. It defaults to i686-w64-mingw32. To build a 64bit binary, specify x86_64-w64-mingw32.
PREFIX
Prefix to the directory where dependent libraries are installed. It defaults to /usr/local/$HOST. -I$PREFIX/include will be added to CPPFLAGS. -L$PREFIX/lib will be added to LDFLAGS. $PREFIX/lib/pkgconfig will be set to PKG_CONFIG_LIBDIR.

For example, to build a 64bit binary do this:

$ HOST=x86_64-w64-mingw32 ./mingw-config

If you want libaria2 dll with --enable-libaria2, then don't use ARIA2_STATIC=yes and prepare the DLL version of external libraries.

 

Building documentation

Sphinx is used to building the documentation. aria2 man pages will be build when you run make if they are not up-to-date. You can also build an HTML version of the aria2 man page by make html. The HTML version manual is also available online (Russian translation, Portuguese translation).

BitTorrent

About file names

The file name of the downloaded file is determined as follows:

single-file mode
If "name" key is present in .torrent file, the file name is the value of "name" key. Otherwise, the file name is the base name of .torrent file appended by ".file". For example, .torrent file is "test.torrent", then file name is "test.torrent.file". The directory to store the downloaded file can be specified by -d option.
multi-file mode
The complete directory/file structure mentioned in .torrent file is created. The directory to store the top directory of downloaded files can be specified by -d option.

Before download starts, a complete directory structure is created if needed. By default, aria2 opens at most 100 files mentioned in .torrent file, and directly writes to and reads from these files. The number of files to open simultaneously can be controlled by --bt-max-open-files option.

DHT

aria2 supports mainline compatible DHT. By default, the routing table for IPv4 DHT is saved to $XDG_CACHE_HOME/aria2/dht.dat and the routing table for IPv6 DHT is saved to $XDG_CACHE_HOME/aria2/dht6.dat unless files exist at $HOME/.aria2/dht.dat or $HOME/.aria2/dht6.dat. aria2 uses the same port number to listen on for both IPv4 and IPv6 DHT.

UDP tracker

UDP tracker support is enabled when IPv4 DHT is enabled. The port number of the UDP tracker is shared with DHT. Use --dht-listen-port option to change the port number.

Other things should be noted

  • -o option is used to change the file name of .torrent file itself, not a file name of a file in .torrent file. For this purpose, use --index-out option instead.
  • The port numbers that aria2 uses by default are 6881-6999 for TCP and UDP.
  • aria2 doesn't configure port-forwarding automatically. Please configure your router or firewall manually.
  • The maximum number of peers is 55. This limit may be exceeded when the download rate is low. This download rate can be adjusted using --bt-request-peer-speed-limit option.
  • As of release 0.10.0, aria2 stops sending request messages after selective download completes.

Metalink

The current implementation supports HTTP(S)/FTP/SFTP/BitTorrent. The other P2P protocols are ignored. Both Metalink4 (RFC 5854) and Metalink version 3.0 documents are supported.

For checksum verification, md5, sha-1, sha-224, sha-256, sha-384, and sha-512 are supported. If multiple hash algorithms are provided, aria2 uses a stronger one. If whole file checksum verification fails, aria2 doesn't retry the download and just exits with a non-zero return code.

The supported user preferences are version, language, location, protocol, and os.

If chunk checksums are provided in the Metalink file, aria2 automatically validates chunks of data during download. This behavior can be turned off by a command-line option.

If a signature is included in a Metalink file, aria2 saves it as a file after the completion of the download. The file name is download file name + ".sig". If the same file already exists, the signature file is not saved.

In Metalink4, a multi-file torrent could appear in metalink:metaurl element. Since aria2 cannot download 2 same torrents at the same time, aria2 groups files in metalink:file element which has the same BitTorrent metaurl, and downloads them from a single BitTorrent swarm. This is a basically multi-file torrent download with file selection, so the adjacent files which are not in Metalink document but share the same piece with the selected file are also created.

If relative URI is specified in metalink:url or metalink:metaurl element, aria2 uses the URI of Metalink file as base URI to resolve the relative URI. If relative URI is found in the Metalink file which is read from the local disk, aria2 uses the value of --metalink-base-uri option as base URI. If this option is not specified, the relative URI will be ignored.

Metalink/HTTP

The current implementation only uses rel=duplicate links. aria2 understands Digest header fields and check whether it matches the digest value from other sources. If it differs, drop the connection. aria2 also uses this digest value to perform checksum verification after the download is finished. aria2 recognizes geo value. To tell aria2 which location you prefer, you can use --metalink-location option.

netrc

netrc support is enabled by default for HTTP(S)/FTP/SFTP. To disable netrc support, specify -n command-line option. Your .netrc file should have correct permissions(600).

WebSocket

The WebSocket server embedded in aria2 implements the specification defined in RFC 6455. The supported protocol version is 13.

libaria2

The libaria2 is a C++ library that offers aria2 functionality to the client code. Currently, libaria2 is not built by default. To enable libaria2, use --enable-libaria2 configure option. By default, only the shared library is built. To build a static library, use --enable-static configure option as well. See libaria2 documentation to know how to use API.

References

 来自https://github.com/aria2/aria2

------------------------------------------------

 

Aria2+AriaNG在VPS上实现离线下载功能

Aria2(官网)和AriaNG(官网)到底是何方神圣呢,简单来讲,前者是一个下载工具,在命令行下可以用aria2c命令来下载(有点儿像wget?),这个程序之所以强大在于其不仅支持http和ftp,还支持bt,至于后者则是为aria2提供了一个可视化的web界面。

Aria2+AriaNG在VPS上实现离线下载功能

1.安装aria2
以CentOS 7为例,Debian大同小异
yum install epel-release -y
yum install aria2 -y
2.后台运行aria2(命令中的Token换成自己的)
aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all --rpc-secret=TOKEN -D
3.如果是CentOS 7,需要设置firewalld开放6800端口,若VPS没装firewalld,则可跳过此步骤
firewall-cmd --zone=public --add-port=6800/tcp --permanent
firewall-cmd --reload
4.安装ariaNG
ariaNG实际上就是一个网页程序,可以自行搭建Web环境,可选VestaCP,LNMP等等,将ariaNG下载解压到web目录下即可(注:ariaNG不需要数据库和php支持)
5.访问ariaNG,如果出现aria2未连接的情况,需要设置一下:

----------

基于Aria2的免配置下载软件-Photon


上面的《用Aria2+AriaNG在VPS上实现离线下载功能》,当时介绍过aria2以及他的网页界面AriaNG,但是手动配置相对较为繁琐,最近发现了GitHub上的一个项目,名称是Photon,这是一个基于Aria2的桌面下载软件,作者称其为Light-weight(轻量级),但30+M的体积着实不小了…不过软件界面比较友好,而且无广告,支持Mac、Windows,据说作者会在近期加入对Linux的支持,只是不知道能否远程访问。

Photon:基于Aria2的免配置下载软件

Photon是基于Aria2,所以Aria2的插件也能通过RPC实现,可使用的一些插件包括迅雷离线百度网盘115等(在各个插件的设置里设置上Photon的RPC配置即可使用),Photon的RPC默认配置如下
URL: http://127.0.0.1:6800/jsonrpc     Host: 127.0.0.1     Port: 6800   
-------------------------

A lightweight multi-threaded downloader based on aria2.


Languages: English 中文

Photon

Photon is a lightweight multi-threaded downloader based on aria2. It supports HTTP/HTTPSMagnet linksBitTorrentand Metalink.
Photon is cross platform. It has macOS and Windows releases now and will have Linux release soon.
For Web frontend of aria2, please have a look at Photon WebUI.

Installation

Screenshots

Mac
mac-donwloading

Extensions

Since Photon uses aria2 as download core, all of the extensions that support aria2 via RPC are also Photon compatible.
The default RPC configuration for Photon and aria2:
Some popular extensions:

Development

# install dependencies
npm install

# serve with hot reload at localhost:9080
npm run dev

# build electron application for production
npm run build

# run unit & end-to-end tests
npm test


# lint all JS/Vue component files in `src/`
npm run lint
This project was generated with electron-vue@7c4e3e9 using vue-cli. Documentation about the original structure can be found here.
from https://github.com/alanzhangzm/Photon
( 下载软件Photon

Photon是一款基于 aria2 的开源下载软件,支持 HTTP/HTTPS,磁力链,BT 和 Metalink。目前支持Mac OS 和 Windows 平台。可以直接使用基于 RPC 协议的 aria2 插件。

[repo owner=”alanzhangzm” name=”Photon”])
 ------------------------------------------------------

利用VPS打造 无限空间在线播放离线网盘(Debian/Ubuntu)


近两天一直都在折腾VPS挂载谷歌云盘打造无限容量的。虽然说网上各类教程非常多,但是要做到全套开机自启,自动上传,自动更新还是有些麻烦的。
本次教程全套组件为:Lnmp+Aria2+Rclone+DirectoryLister+Aria2Ng
本篇博文是利用Vultr Ubuntu 16 X64做的搭建实例,首先感谢Rats提供VPS作为示范。由于Linux系统的多样性,不保证按照此教程搭建一定成功。

准备工作

  • 一个域名:本篇教程使用的域名为aria2down.tk
    使用时请自行将aria2down.tk更换为自己的域名
  • 一个VPS:要求KVM 1核 512M内存以上,硬盘空间建议50G以上(由于是先下载到VPS再上传到谷歌云盘里,所以硬盘限制了单次能下载文件的最大大小)。
  • 谷歌云盘账号:需要一个无限容量的谷歌云盘账号。如果没有请自寻购买(价格大概15-20元)。
需要的东西并不多,其中域名为可选项。

搭建网站环境

由于这次教程中Aria2Ng和DirectoryLister需要nginx和php的支持,所以我们先来安装Lnmp。这里推荐我一直使用的一键包Oneinstack
apt-get update
apt-get -y install wget screen curl python zip unzip sudo vim
#由于shell的局限性,请先复制上方内容执行完再复制下方执行
wget http://mirrors.linuxeye.com/oneinstack.tar.gz
tar xzf oneinstack.tar.gz && rm -f oneinstack.tar.gz
cd oneinstack
screen -S oneinstack
./install.sh
交互记录
Please input SSH port(Default: 22): #回车

Do you want to enable iptables? [y/n]: n

Do you want to install Web server? [y/n]: y

Please select Nginx server:
        1. Install Nginx
        2. Install Tengine
        3. Install OpenResty
        4. Do not install
Please input a number:(Default 1 press Enter) #回车

Please select Apache server:
        1. Install Apache-2.4
        2. Install Apache-2.2
        3. Do not install
Please input a number:(Default 3 press Enter) #回车

Please select tomcat server:
        1. Install Tomcat-8
        2. Install Tomcat-7
        3. Install Tomcat-6
        4. Do not install
Please input a number:(Default 4 press Enter) #回车

Do you want to install Database? [y/n]: n

Do you want to install PHP? [y/n]: y

Please select a version of the PHP:
        1. Install php-5.3
        2. Install php-5.4
        3. Install php-5.5
        4. Install php-5.6
        5. Install php-7.0
        6. Install php-7.1
        7. Install php-7.2
Please input a number:(Default 5 press Enter) #回车

Do you want to install opcode cache of the PHP? [y/n]: y
Please select a opcode cache of the PHP:
        1. Install Zend OPcache
        3. Install APCU
Please input a number:(Default 1 press Enter) #回车

Do you want to install ionCube? [y/n]: n

Do you want to install ImageMagick or GraphicsMagick? [y/n]: n

Do you want to install Pure-FTPd? [y/n]: n

Do you want to install phpMyAdmin? [y/n]: n

Do you want to install redis? [y/n]: n

Do you want to install memcached? [y/n]: n

Do you want to install HHVM? [y/n]: n
然后脚本就开始自动安装nginxphp环境了
这段时间我们可以用来设置域名的绑定,本篇教程是将Aria2Ng的域名定为aria2down.comDirectoryLister设置为www.aria2down.com
Oneinstack安装速度很快,大概一顿饭的功夫就能安装完毕。
Please restart the server and see if the services start up fine.
Do you want to restart OS ? [y/n]: y
看到如下字样,输入y重启即可。

添加站点程序

我们先不慌部署aria2,先把网站程序上传上去。使用oneinstack创建站点。
首先创建的是Aria2Ng的站点
cd /root/oneinstack
./vhost.sh
交互记录
#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
    1. Use HTTP Only
    2. Use your own SSL Certificate and Key
    3. Use Let's Encrypt to Create SSL Certificate and Key
    q. Exit
Please input the correct option: 1

Please input domain(example: www.example.com): aria2down.tk          
domain=aria2down.tk

Please input the directory for the domain:aria2down.tk :#回车
(Default directory: /data/wwwroot/aria2down.tk): 
Virtual Host Directory=/data/wwwroot/aria2down.tk

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: n

Do you want to add hotlink protection? [y/n]: n

Allow Rewrite rule? [y/n]: n

Allow Nginx/Tengine/OpenResty access_log? [y/n]: n

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  aria2down.tk
Virtualhost conf:             /usr/local/nginx/conf/vhost/aria2down.tk.conf
Directory of:                 /data/wwwroot/aria2down.tk
大家将aria2down.tk更换成自己的域名即可,接下来是上传站点程序。
cd /data/wwwroot/aria2down.tk
wget "https://github.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/raw/master/website/Aria2Ng.zip"
unzip Aria2Ng.zip && rm -f Aria2Ng.zip
现在我们就可以尝试打开自己域名看看能不能访问Aria2Ng.
接下来部署DirectoryLister
cd /root/oneinstack
./vhost.sh
交互记录
#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################

What Are You Doing?
    1. Use HTTP Only
    2. Use your own SSL Certificate and Key
    3. Use Let's Encrypt to Create SSL Certificate and Key
    q. Exit
Please input the correct option: 1

Please input domain(example: www.example.com): www.aria2down.tk
domain=www.aria2down.tk

Please input the directory for the domain:www.aria2down.tk :
(Default directory: /data/wwwroot/www.aria2down.tk): 
Virtual Host Directory=/data/wwwroot/www.aria2down.tk

Create Virtul Host directory......
set permissions of Virtual Host directory......

Do you want to add more domain name? [y/n]: n

Do you want to add hotlink protection? [y/n]: n

Allow Rewrite rule? [y/n]: n

Allow Nginx/Tengine/OpenResty access_log? [y/n]: n

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Reload Nginx......

#######################################################################
#       OneinStack for CentOS/RadHat 6+ Debian 7+ and Ubuntu 12+      #
#       For more information please visit https://oneinstack.com      #
#######################################################################
Your domain:                  www.aria2down.tk
Virtualhost conf:             /usr/local/nginx/conf/vhost/www.aria2down.tk.conf
Directory of:                 /data/wwwroot/www.aria2down.tk
大家将www.aria2down.tk更换成自己的域名即可,接下来是上传站点程序。
cd /data/wwwroot/www.aria2down.tk
wget "https://github.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/raw/master/website/DirectoryLister.zip"
unzip DirectoryLister.zip && rm -f DirectoryLister.zip
mkdir Download
mkdir Cloud
现在我们就可以尝试打开自己域名看看能不能访问DirectoryLister.
如果需要更改版权请去resources/themes/bootstrap更改。
教程到这里,前端已经部署完毕,接下来是后端的部署。

编译安装Aria2

在这里我推荐大家使用编译来安装aria2,虽然耗时比较久,但是不容易出错。
在编译之前,先要安装GCC-4.9。由于安装BBR魔改版自动把GCC4.9安装上了,BBR加速也很有用。
编译安装
wget https://github.com/aria2/aria2/releases/download/release-1.33.1/aria2-1.33.1.tar.gz
tar xzvf aria2-1.33.1.tar.gz
cd aria2-1.33.1
./configure
make
make install 
编译过程有些慢,大概需要10-15分钟。大家可以喝口水等等。编译完成后我们可以输入aria2c测试是否可以运行。

接下来开始配置aria2的配置文件
mkdir "/root/.aria2" && cd "/root/.aria2"
wget "https://raw.githubusercontent.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/master/sh/aria2.conf"
wget "https://raw.githubusercontent.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/master/sh/autoupload.sh"
wget "https://raw.githubusercontent.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/master/sh/dht.dat"
wget "https://raw.githubusercontent.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/master/sh/trackers-list-aria2.sh"
echo '' > /root/.aria2/aria2.session
chmod +x /root/.aria2/trackers-list-aria2.sh
chmod +x /root/.aria2/autoupload.sh
chmod 777 /root/.aria2/aria2.session
wget --no-check-certificate https://raw.githubusercontent.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/master/sh/aria2 -O /etc/init.d/aria2
chmod +x /etc/init.d/aria2
update-rc.d -f aria2 defaults
有两个配置文件需要修改,我们先修改aria2.conf。aria2.conf为aria2的配置文件。
输入命令vim aria2.conf,按i进行编辑
## 用户必改项 ##
# 文件的保存路径(可使用绝对路径或相对路径), 默认: 当前启动位置
dir=
# 设置的RPC授权令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 选项
rpc-secret=
dir为下载目录。在这里,我设置为/data/wwwroot/www.aria2down.tk/Download
rpc-secret为访问秘钥,是Aria2Ng连接Aria2唯一的验证。输入自己记得的密码即可。
输入完后按esc,输入:wq保存文件。
autoupload.sh是下载文件后自动将下载文件移动到挂载目录下的脚本。我们暂时不进行配置,等到rclone时再进行配置。我们先配置trackers-list-aria2.sh脚本。
trackers-list-aria2.sh脚本是自动更新bt下载的trackers服务器的脚本。我们并不需要修改脚本内容,只需要把它添加进入计划任务。输入crontab -e进入任务计划管理.
编辑方法与vim相同,将以下两句添加进去。
0 3 */7 * * /root/.aria2/trackers-list-aria2.sh
*/5 * * * * /usr/sbin/service aria2 start
保存后aria2即配置完毕,我们输入bash /etc/init.d/aria2 start启动aria2。
启动成功时我们即可看到以下配置信息:


挂载谷歌云盘

一般VPS的硬盘是不够我们用过瘾的。所以我们可以挂载无限空间的谷歌云盘来爽一把。
cd /root
wget https://raw.githubusercontent.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/master/sh/rclone_debian.sh  && bash rclone_debian.sh
rm -f rclone_debian.sh
rclone config
交互信息
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> aria2down  #随便填,后面要用到
Type of storage to configure.
Choose a number from below, or type in your own value
 1 / Alias for a existing remote
   \ "alias"
 2 / Amazon Drive
   \ "amazon cloud drive"
 3 / Amazon S3 (also Dreamhost, Ceph, Minio, IBM COS)
   \ "s3"
 4 / Backblaze B2
   \ "b2"
 5 / Box
   \ "box"
 6 / Cache a remote
   \ "cache"
 7 / Dropbox
   \ "dropbox"
 8 / Encrypt/Decrypt a remote
   \ "crypt"
 9 / FTP Connection
   \ "ftp"
10 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
11 / Google Drive
   \ "drive"
12 / Hubic
   \ "hubic"
13 / Local Disk
   \ "local"
14 / Microsoft Azure Blob Storage
   \ "azureblob"
15 / Microsoft OneDrive
   \ "onedrive"
16 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
17 / Pcloud
   \ "pcloud"
18 / QingCloud Object Storage
   \ "qingstor"
19 / SSH/SFTP Connection
   \ "sftp"
20 / Webdav
   \ "webdav"
21 / Yandex Disk
   \ "yandex"
22 / http Connection
   \ "http"
Storage> 11 #选择11
Google Application Client Id - leave blank normally.
client_id> #留空
Google Application Client Secret - leave blank normally.
client_secret> #留空
Scope that rclone should use when requesting access from drive.
Choose a number from below, or type in your own value
 1 / Full access all files, excluding Application Data Folder.
   \ "drive"
 2 / Read-only access to file metadata and file contents.
   \ "drive.readonly"
   / Access to files created by rclone only.
 3 | These are visible in the drive website.
   | File authorization is revoked when the user deauthorizes the app.
   \ "drive.file"
   / Allows read and write access to the Application Data folder.
 4 | This is not visible in the drive website.
   \ "drive.appfolder"
   / Allows read-only access to file metadata but
 5 | does not allow any access to read or download file content.
   \ "drive.metadata.readonly"
scope> 1 #选择1
ID of the root folder - leave blank normally.  Fill in to access "Computers" folders. (see docs).
root_folder_id> #留空
Service Account Credentials JSON file path  - leave blank normally.
Needed only if you want use SA instead of interactive login.
service_account_file> #留空
Remote config
Use auto config?
 * Say Y if not sure
 * Say N if you are working on a remote or headless machine or Y didn't work
y) Yes
n) No
y/n> n  #选择n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/oauth2/auth....  #复制到浏览器打开,获取验证码
Log in and authorize rclone for access
Enter verification code>  #填入上面获取到的验证码
Configure this as a team drive?
y) Yes
n) No
y/n> y  #选择y
Fetching team drive list...
No team drives found in your account--------------------
[Rats]
client_id = 
client_secret = 
service_account_file = 
token = {"access_token":"ya29.GltFBd7UJN2qrxdG8FnG_rMuB18ogb8QlujdL7glvXtfV"}
team_drive = 
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y  #选择y
Current remotes:

Name                 Type
====                 ====
aria2down            drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q  #选择q退出
退出后我们来设置下rclone自启动脚本。
wget https://raw.githubusercontent.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng/master/sh/rcloned
vim rcloned
我们要修改以下内容
NAME="" #rclone name名
REMOTE='' #远程文件夹
LOCAL='' #挂载地址
NAME 即是刚刚rclone配置是输入的name。这里我填写的是aria2down
REMOTE 填写的是谷歌云盘中文件夹的名称,我在云盘里新建了一个chikage的文件夹,所以这里填写的就是chikage
LOCAL 填写挂载在vps中位置的地址,在这里我填写的是/data/wwwroot/www.aria2down.tk/Cloud
输入完成后保存。我们将其设置自启,并尝试启动。
mv rcloned /etc/init.d/rcloned
chmod +x /etc/init.d/rcloned
update-rc.d -f rcloned defaults
bash /etc/init.d/rcloned start
检测信息显示rclone启动成功即可:
最后我们配置下autoupload.sh,输入vim /root/.aria2/autoupload.sh
downloadpath='' #下载目录
rclone=''   #rclone挂载的目录
downloadpath 为之前在aria2.conf dir的值。
rclone 为刚刚填入rcloned LOCAL的值
保存后即完成了全套离线下载方案的部署。

结束语

这个教程编写大概耗了我一天的时间,其中的绝大多数脚本由自己编写并调试,在这过程中也遇到许多问题。希望我这篇教程能给你带来帮助.

脚本地址:https://github.com/chiakge/Aria2-Rclone-DirectoryLister-Aria2Ng

No comments:

Post a Comment