centos 安装 aria2 webui 实现网页下载

centos aria2 webui

安装aria2

安装 rpmforge源
wget http://repository.it4i.cz/mirrors/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

yum 安装

yum -y install aria2

简单用下命令

直接下载
aria2c http://3w.gd.6122.net:8080/uploadFile/2017/CommonDll.zip
使用两个连接
aria2c -x2  http://3w.gd.6122.net:8080/uploadFile/2017/CommonDll.zip
断点续传
aria2c -c -s 5 http://example.org/mylinux.iso
-c : 断点续传
-s : 使用线程数

配置

$ mkdir /etc/aria2/
$ vim /etc/aria2/aria2.conf

#用户名
#rpc-user=user
#密码
#rpc-passwd=passwd
#上面的认证方式不建议使用,建议使用下面的token方式
#设置加密的密钥
#rpc-secret=token
#允许rpc
enable-rpc=true
#允许所有来源, web界面跨域权限需要
rpc-allow-origin-all=true
#允许外部访问,false的话只监听本地端口
rpc-listen-all=true
#RPC端口, 仅当默认端口被占用时修改
rpc-listen-port=6800
#最大同时下载数(任务数), 路由建议值: 3
max-concurrent-downloads=5
#断点续传
continue=true
#同服务器连接数
max-connection-per-server=5
#最小文件分片大小, 下载线程数上限取决于能分出多少片, 对于小文件重要
min-split-size=10M
#单文件最大线程数, 路由建议值: 5
split=10
#下载速度限制
max-overall-download-limit=0
#单文件速度限制
max-download-limit=0
#上传速度限制
max-overall-upload-limit=0
#单文件速度限制
max-upload-limit=0
#断开速度过慢的连接
#lowest-speed-limit=0
#验证用,需要1.16.1之后的release版本
#referer=*
#文件保存路径, 默认为当前启动位置
dir=/root/downloads
#文件缓存, 使用内置的文件缓存, 如果你不相信Linux内核文件缓存和磁盘内置缓存时使用, 需要1.16及以上版本
#disk-cache=0
#另一种Linux文件缓存方式, 使用前确保您使用的内核支持此选项, 需要1.15及以上版本(?)
#enable-mmap=true
#文件预分配, 能有效降低文件碎片, 提高磁盘性能. 缺点是预分配时间较长
#所需时间 none < falloc ? trunc << prealloc, falloc和trunc需要文件系统和内核支持
file-allocation=prealloc

配置文件启动(推荐)
后台启动

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

启动脚本

$ vi /etc/init.d/aria2
#!/bin/bash
#
# aria2 - this script starts and stops the aria2 daemon
#
# chkconfig:   - 85 15
# description: Aria2 - Download Manager
# processname: aria2c
# config:      /etc/aria2/aria2.conf
# pidfile:     

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0

aria2c="/usr/bin/aria2c"
ARIA2C_CONF_FILE="/etc/aria2/aria2.conf"
options=" --conf-path=$ARIA2C_CONF_FILE -D "

RETVAL=0

start() {
        # code here to start the program
        echo -n "Starting aria2c daemon."
        ${aria2c} ${options}
        RETVAL=$?
        echo
}

stop() {
        echo -n "Shutting down aria2c daemon."
        /usr/bin/killall aria2c
        RETVAL=$?
        echo
}

status() {
        ID=$(/bin/ps -ef | grep 'aria2c' | grep -v 'grep' | awk '{print $2}')
        if [[ "x$ID" != "x" ]]; then
                echo "Aria2 is running."
        else
                echo "Aria2 is not running."
        fi
}

restart() {
        stop
        sleep 3
        start
}

case "$1" in
        start)
                start
                ;;
        stop)
                stop
                ;;
        status) 
                status
                ;;
        restart)
                restart
                ;;
        *)
                echo "Usage: service aria2c {start|stop|restart}"
                RETVAL=1                             
esac                                                 

exit $RETVAL

搭配Aria2 Web UI

git clone https://github.com/ziahamza/webui-aria2
在程序目录下
python -m SimpleHTTPServer 9999
然后在你的浏览器就可以访问了
嫌输入IP和端口麻烦的话,可以用nginx做个反向代理加个域名

具体的自己摸索吧。

posted on 2017-01-18 21:14  扶朕起来,朕还能送  阅读(9977)  评论(0编辑  收藏  举报

导航