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做個反向代理加個域名

具體的自己摸索吧。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM