Install Aria2 and Yaaw on CentOS for Offline Downloads

aria2yaawcentos offline downloadaria2 configurationweb download manager
Published·Modified·

Previously, I shared how to build a CDN node using an idle VPS: Smart Resolution + Nginx Reverse Proxy, Self-Built CDN Acceleration Node. I felt the VPS was still not fully utilized, so we can also use aria2 + yaaw to achieve offline downloads.

Download Interface

Install Aria2

Aria2 is a lightweight multi-protocol and multi-source command-line download tool. It supports HTTP/HTTPS, FTP, SFTP, BitTorrent, and Metalink. Aria2 can be operated via its built-in JSON-RPC and XML-RPC interfaces.

CentOS's built-in software repositories do not include aria2. You need to install EPEL first, then install aria2. Execute the following commands:

# Install EPEL repository
yum -y install epel-release
# Install aria2
yum -y install aria2
# Check aria2 version
aria2c -v

After installation, you can use aria2 for multi-threaded downloads. Common parameters are as follows:

  • -o: Download and rename
  • -x: Number of threads to use (more threads = faster speed, max 16)
  • -c: Resume broken downloads

Example: Download a file using 16 threads

aria2c -x 16 http://soft.xiaoz.top/windows/ChromeStandaloneSetup.exe

Configure Aria2

Aria2 has many configuration options. If you want to perform offline downloads via a web interface, you need to enable JSON-RPC support. Modify the following rules appropriately and save them as /home/soft/aria2/aria2.conf:

# Create download directory
mkdir -p /home/download
# Create folder
mkdir -p /home/soft/aria2
# Create session file
touch /home/soft/aria2/aria2.session
# Save the following content as aria2.conf
vi /home/soft/aria2/aria2.conf
# File save path (absolute or relative path), default: current startup location
dir=/home/download
# Enable disk cache, 0 to disable, requires version 1.16+, default: 16M
#disk-cache=32M
# File pre-allocation method, effectively reduces disk fragmentation, default: prealloc
# Pre-allocation time: none < falloc ? trunc < prealloc
# falloc and trunc require filesystem and kernel support
# NTFS recommends falloc, EXT3/4 recommends trunc, MAC requires commenting this out
file-allocation=trunc
# Resume broken downloads
continue=true

## Download Connection Settings ##

# Maximum number of simultaneous download tasks, modifiable at runtime, default: 5
max-concurrent-downloads=5
# Connections per server, specified when adding, default: 1
max-connection-per-server=5
# Minimum file chunk size, modifiable when adding, range 1M-1024M, default: 20M
# Assuming size=10M, a 20MiB file uses two sources; a 15MiB file uses one source
min-split-size=10M
# Maximum threads per task, modifiable when adding, default: 5
split=32
# Overall download speed limit, modifiable at runtime, default: 0
#max-overall-download-limit=0
# Single task download speed limit, default: 0
#max-download-limit=0
# Overall upload speed limit, modifiable at runtime, default: 0
#max-overall-upload-limit=0
# Single task upload speed limit, default: 0
#max-upload-limit=0
# Disable IPv6, default: false
disable-ipv6=true

## Progress Saving Settings ##

# Read download tasks from session file
input-file=/home/soft/aria2/aria2.session
# Save 'error/incomplete' download tasks to session file when Aria2 exits
save-session=/home/soft/aria2/aria2.session
# Periodically save session, 0 means save only on exit, requires version 1.16.1+, default: 0
#save-session-interval=60

## RPC Settings ##

# Enable RPC, default: false
enable-rpc=true
# Allow all origins, default: false
rpc-allow-origin-all=true
# Allow non-external access, default: false
rpc-listen-all=true
# Event polling method, values: [epoll, kqueue, port, poll, select], defaults vary by system
#event-poll=select
# RPC listen port, modifiable if port is occupied, default: 6800
#rpc-listen-port=6800
# Set RPC authorization token, new feature in v1.18.4, replaces --rpc-user and --rpc-passwd options
#rpc-secret=<TOKEN>
# Set RPC access username, deprecated in new versions, recommend using --rpc-secret
#rpc-user=<USER>
# Set RPC access password, deprecated in new versions, recommend using --rpc-secret
#rpc-passwd=<PASSWD>

## BT/PT Download Settings ##

# Automatically start BT task when downloading a torrent (ending in .torrent), default: true
#follow-torrent=true
# BT listen port, use if port is blocked, default: 6881-6999
listen-port=51413
# Maximum connections per torrent, default: 55
#bt-max-peers=55
# Enable DHT function, disable for PT, default: true
enable-dht=false
# Enable IPv6 DHT function, disable for PT
#enable-dht6=false
# DHT network listen port, default: 6881-6999
#dht-listen-port=6881-6999
# Local node lookup, disable for PT, default: false
#bt-enable-lpd=false
# Seed exchange, disable for PT, default: true
enable-peer-exchange=false
# Limit per seed, useful for few-seed PT, default: 50K
#bt-request-peer-speed-limit=50K
# Client spoofing, required for PT
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
# Stop seeding automatically when share ratio reaches this number, 0 means always seed, default: 1.0
seed-ratio=0
# Force save session even if task is complete, default: false
# Newer versions retain .aria2 files after task completion
#force-save=false
# BT verification settings, default: true
#bt-hash-check-seed=true
# Continue previous BT tasks without re-verifying, default: false
bt-seed-unverified=true
# Save magnet link metadata as torrent file (.torrent), default: false
bt-save-metadata=true

Next, run the following command to make aria2 run in the background. If it fails to start, check the error message.

# Run aria2c
aria2c --conf-path=/home/soft/aria2/aria2.conf
# If you need it to run persistently, modify to:
nohup aria2c --conf-path=/home/soft/aria2/aria2.conf &

Add Verification

In aria2 version 1.18.4 and above, RPC secret verification was added. If you do not want the interface to be public, uncomment the rpc-secret= line in the configuration above and fill in your own key. The interface address format will be http://token:key@IP:6800/jsonrpc.

Install Yaaw

Yaaw is a web interface management tool for aria2, implemented entirely with HTML + JavaScript, so no script environment is required. Simply download it to your local machine or deploy it to your web service.

# Download yaaw
wget https://github.com/binux/yaaw/archive/master.zip
# Unzip
unzip master.zip
# Move
mv yaaw-master/* ./

If everything goes smoothly, visiting http://yourdomain.com/index.html will show the Yaaw interface, as shown in the screenshot below.

Yaaw Interface

Set Interface

Click the Settings button in the top right corner and fill in the web interface address. Without a password, the interface address is http://IP:6800/jsonrpc. If you enabled rpc-secret=, the address is http://token:key@IP:6800/jsonrpc. Note that you must also allow port 6800 through the firewall to avoid download issues. In production environments, please set a password for aria2 to prevent malicious downloads.

Interface Settings

This article references part of the content from: Download Tool - Aria2, Build Your Own Offline Download Server