Aria2 Linux 安装

发布于 2022-01-23  1 次阅读


脚本安装

一键脚本安装:

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh

脚本备份:

wget -N --no-check-certificate https://raw.githubusercontent.com/ADDGM/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh

其他操作

service aria2 start    #启动
service aria2 stop    #停止
service aria2 restart    #重启
service aria2 status    #查看状态

配置文件:/root/.aria2/aria2.conf

编译安装

创建.aria2 目录:

mkdir /root/aria2

CentOS 7+:

yum -y install aria2 cd /root/aria2 && wget https://github.com/aria2/aria2/releases/download/release-1.35.0/aria2-1.35.0.tar.gz

升级gcc:

编译aria2需要升级一下gcc,最低要求 gcc >= 4.8.2,如果gcc已经在符合这个要求就可以跳到下一步。

# 添加一个源 
cd /etc/yum.repos.d wget http://people.centos.org/tru/devtools-2/devtools-2.repo

# 安装所需包 
yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

# 保存原来的版本
mv /usr/bin/gcc /usr/bin/gcc-4.4.7
mv /usr/bin/g++ /usr/bin/g++-4.4.7
mv /usr/bin/c++ /usr/bin/c++-4.4.7

# 链接到新版本的gcc
ln -s /opt/rh/devtoolset-2/root/usr/bin/gcc /usr/bin/gcc
ln -s /opt/rh/devtoolset-2/root/usr/bin/c++ /usr/bin/c++
ln -s /opt/rh/devtoolset-2/root/usr/bin/g++ /usr/bin/g++

# 查看当前gcc版本
gcc --version

保存为:update_gcc.sh

给予update_gcc.sh文件可执行权限并执行

chmod 754 update_gcc.sh && ./update_gcc.sh

解压

tar zxvf aria2-1.35.0.tar.gz && cd aria2-1.35.0 && mkdir build && cd build && ../configure && make && make install

配置 Aria2

创建 aria2.session 文件:

touch /root/aria2/aria2.session

创建 aria2.log:

touch /root/aria2/aria2.log

创建 aria2.conf:

touch /root/aria2/aria2.conf

启动:

aria2

查询 aria2c 版本

aria2c -v

设置自启

vim /etc/rc.d/rc.local

最后一行添加:

aria2c --conf-path=/root/aria2/aria2.conf -D

找到VPS目录 /etc/systemd/system,创建一个名为 aria2.service 的文件

[Unit]
Description=Aria2
After=syslog.target
After=network.target

[Service]
Type=forking
ExecStart=/usr/bin/aria2c --conf-path=/root/aria2/aria2.conf
Restart=always

[Install]
WantedBy=multi-user.target