下載源碼
安裝一些必要的依賴環(huán)境
apt install -y libcurl4-openssl-dev libevent-dev \
ca-certificates libssl-dev pkg-config \
build-essential intltool libgcrypt-dev \
libssl-dev libxml2-dev
下載最新的aria2的源碼:
wget --no-check-certificate https://github.com/aria2/aria2/releases/download/release-1.31.0/aria2-1.31.0.tar.gz
tar zxf aria2-1.31.0.tar.gz
cd ./aria2-1.31.0
修改源碼
Aria2的參數(shù)中-max-server-connection
和-min-split-files
很大程度上決定了網(wǎng)盤的下載速度千扶。
在這里我將-max-server-connection
最高設(shè)置為256,-min-split-files
最小設(shè)置為256k滥沫。
#aira2的基本配置選項(xiàng)大多都存儲(chǔ)在文件OptionHandlerFactory.cc中
vi src/OptionHandlerFactory.cc
#定位到441行
#將服務(wù)器最大連接數(shù)16修改為256
OptionHandler* op(new NumberOptionHandler(PREF_MAX_CONNECTION_PER_SERVER,
TEXT_MAX_CONNECTION_PER_SERVER,
// "1", 1, 16, 'x'));
"1", 1, 256, 'x'));
#定位到第503行
#將最文件分片大小設(shè)置為256_k
#到此源代碼需要修改的地方改完了
OptionHandler* op(new UnitNumberOptionHandler(
//PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, "1M", 1_m, 1_g, 'k'));
PREF_MIN_SPLIT_SIZE, TEXT_MIN_SPLIT_SIZE, "1M", 256_k, 1_g, 'k'));
編譯前的參數(shù)設(shè)置
./configure
編譯
make
編譯完成之后
cp src/aria2c /usr/local/bin
查看安裝是否成功
aria2c -v
如果能顯示版本號(hào)狐榔,就表示成功。
配置
在/etc里新建一個(gè)aria2的目錄,新建配置文件aria2.conf
mkdir -p /etc/aria2
vi /etc/aria2/aria2.conf
插入以下內(nèi)容:
dir=/home/wen/Downloads # 這里改成絕對(duì)路徑
disable-ipv6=true
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
rpc-listen-port=6800
continue=true
input-file=/etc/aria2/aria2.session
#rpc-user=admin
#rpc-passwd=password
save-session=/etc/aria2/aria2.session
save-session-interval=7200
max-concurrent-downloads=20
max-connection-per-server=256
min-split-size=256k
#log=/var/log/aria2/aria2.log
# Complete delete .aria2 files
on-download-complete=/etc/aria2/delete_aria2
max-overall-upload-limit=5K
max-upload-limit=5K
follow-torrent=true
#BT
bt-request-peer-speed-limit=200K
#PT download
bt-max-peers=48
listen-port=26834
enable-dht=false
bt-enable-lpd=false
enable-peer-exchange=false
user-agent=uTorrent/341(109279400)(30888)
peer-id-prefix=-UT341-
seed-ratio=0
force-save=true
bt-hash-check-seed=true
bt-seed-unverified=true
bt-save-metadata=true
新建一個(gè)aria2.session建椰,用于存儲(chǔ)正在下載的一些信息
touch /etc/aria2/aria2.session
啟動(dòng)
啟動(dòng)文件配置
#!/bin/sh
### BEGIN INIT INFO
# Provides: aria2
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Aria2 Downloader
### END INIT INFO
case "$1" in
start)
echo -n "Starting aria2cn"
sudo -u root aria2c --conf-path=/etc/aria2/aria2.conf -D
#sudo -u后面的是你正在使用的用戶名雕欺,因?yàn)槲矣玫膔oot
;;
stop)
echo -n "Shutting down aria2c "
killall aria2c
;;
restart)
echo -n "Shutting down aria2c "
killall aria2c
sleep 3
echo -n "Starting aria2c"
sudo -u root aria2c --conf-path=/etc/aria2/aria2.conf -D
#同上面的一樣,根據(jù)自己的用戶名改root棉姐。
;;
*)
echo 'Usage:' `basename $0` '[option]'
echo 'Available option:'
for option in start stop restart
do
echo ' -' $option
done
;;
esac
給啟動(dòng)文件一個(gè)權(quán)限以及開(kāi)機(jī)自動(dòng)運(yùn)行aria2
sudo chmod 755 /etc/init.d/aria2c
update-rc.d aria2c defaults
啟動(dòng)aria2
sudo service aria2c start