安装aria2
sudo apt-get install aria2
aria2配置
创建下载目录
sudo mkdir ~/aria2_download
sudo chmod 777 ~/aria2_download
创建配置文件
sudo mkdir /etc/aria2
sudo touch /etc/aria2/aria2.session
sudo chmod 777 /etc/aria2/aria2.session
sudo vi /etc/aria2/aria2.conf
aria2.conf文件内容
#=========文件保存目录自行修改
dir=/home/fangqi/aria2_download
disable-ipv6=true
#打开rpc的目的是为了给web管理端用
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
#rpc-listen-port=6800
continue=true
input-file=/etc/aria2/aria2.session
save-session=/etc/aria2/aria2.session
max-concurrent-downloads=3
测试aria2安装是否成功
sudo aria2c --conf-path=/etc/aria2/aria2.conf
没有错误提示即为成功,ctrl+c可停止运行;
服务模式开机启动
增加开机启动脚本
sudo vi /etc/init.d/aria2c
添加如下内容:
#!/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 "已开启Aria2c"
sudo aria2c --conf-path=/etc/aria2/aria2.conf -D
;;
stop)
echo -n "已关闭Aria2c"
killall aria2c
;;
restart)
killall aria2c
sudo aria2c --conf-path=/etc/aria2/aria2.conf -D
;;
esac
exit
修改文件权限为755
sudo chmod 755 /etc/init.d/aria2c
添加aria2c服务到开机启动
sudo update-rc.d aria2c defaults
启动服务
sudo service aria2c start
查看服务状态
sudo systemctl status aria2c