美文网首页我用 LinuxLinux学习之路工具癖
和迅雷说再见!手把手教你如何让Windows 10 Ubuntu

和迅雷说再见!手把手教你如何让Windows 10 Ubuntu

作者: 小牛有财 | 来源:发表于2019-07-08 21:25 被阅读7次

    参考文章

    网络构成

    网络拓补图

    如上,简单画了一下我的家庭网络拓补图。这段时间折腾的WSL服务器是一台老旧笔记本电脑,我给它换了颗CPU,加了内存,升级到最新的Windows 10 1903版本,安装了WSL(Ubuntu 18.04),外挂一个硬盘组,在WSL上识别为/mnt/d。今天准备将其打造成下载服务器,看看能不能替代迅雷。

    安装aria2

    这个不用多介绍了,如雷贯耳,号称跨平台“下载神器”的aria2,是一款开源轻量级的多协议命令行下载工具,支持 HTTP/HTTPS、FTP、SFTP、BitTorrent和 Metalink协议,拥有众多第三方支持插件。老规矩,在Windows 10终端上打开PuTTY,连接WSL,开工。

    # apt update
    # apt install aria2
    # aria2c -v
    aria2 version 1.33.1
    Copyright (C) 2006, 2017 Tatsuhiro Tsujikawa
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    ** Configuration **
    Enabled Features: Async DNS, BitTorrent, Firefox3 Cookie, GZip, HTTPS, Message D                                                                                                             igest, Metalink, XML-RPC
    Hash Algorithms: sha-1, sha-224, sha-256, sha-384, sha-512, md5, adler32
    Libraries: zlib/1.2.11 libxml2/2.9.4 sqlite3/3.21.0 GnuTLS/3.5.8 nettle GMP/6.1.                                                                                                             2 c-ares/1.13.0
    Compiler: gcc 7.2.0
      built by  x86_64-pc-linux-gnu
      on        Jan  5 2018 16:55:22
    System: Linux 4.4.0-18362-Microsoft #1-Microsoft Mon Mar 18 12:02:00 PST 2019 x8                                                                                                             6_64
    
    Report bugs to https://github.com/aria2/aria2/issues
    Visit https://aria2.github.io/
    

    版本信息如上,安装成功。

    配置aria2

    启动之前一系列配置:

    # mkdir /etc/aria2
    # cd /etc/aria2
    # touch aria2.conf
    # chmod 744 aria2.conf
    # cd ~
    # mkdir .aria2
    # cd .aria2
    # touch aria2.session
    

    aria2.conf是配置文件,安装包里没有,需要自己生成。可以直接下载我做好的配置文件,点击我的度盘分享下载,提取码:zdhg。
    下载之后,将里面的内容拷贝至aria2.conf里,需要做改动的地方有一个:

    #文件保存路径, 默认为当前启动位置
    dir=/mnt/d/download
    

    这里改成你自己的下载存储路径就可以用了。
    下面启动下载服务,先做两个快捷命令:

    # vi ~/.bashrc
    追加两行:
    alias startaria2c='sudo aria2c --conf-path=/etc/aria2/aria2.conf --enable-rpc -D'
    alias stoparia2c='sudo killall aria2c'
    保存退出
    # source .bashrc
    # startaria2c
    

    这样就可以让aria2服务在后台运行了。用ps看一下:

    # ps -ef
    UID        PID  PPID  C STIME TTY          TIME CMD
    root         1     0  0 12:21 ?        00:00:00 /init
    root        41     1  0 12:21 ?        00:00:00 /usr/sbin/sshd
    root        44    41  0 12:22 ?        00:00:00 sshd: root@pts/0
    root        78    44  0 12:22 pts/0    00:00:00 -bash
    root        98     1  0 12:22 ?        00:04:58 aria2c --conf-path=/etc/aria2/aria2.conf --enable-rpc -D
    

    进程中已经有了。

    安装webui-aria2

    aria2是个命令行下载工具,每下载一个文件都要在aria2c后面加上下载地址,非常不方便。因此一些大神开发了许多可视化外壳,webui-aria2就是其中最著名的。安装webui-aria2前先安装三个基础工具git、screen和nodejs:

    # apt install git screen nodejs -y
    

    资深程序员都知道git是什么吧,用git从github下载webui-aria2:

    # git clone https://github.com/ziahamza/webui-aria2.git
    

    速度比较慢,需要等待一段,成功后当前目录下多了一个webui-aria2目录,进入,启动webui-aria2:

    # screen -S aria2
    # cd webui-aria2
    # node node-server.js
    WebUI Aria2 Server is running on http://localhost:8888
    

    然后依次按下键盘的ctrl、A、D 这三个键,回到前一个会话,这时候webui-aria2已经开始工作了。
    打开Windows浏览器,地址栏输入http://WSL服务器IP:8888,打开webui-aria2画面:

    Aria2 WebUI
    看着还挺清爽的。点击添加下载一个磁力链接,可以满速下载!
    下载测试

    安装yaaw

    比webui-aria2更方便的,就是yaaw。因为我们已经有了apache2服务器,安装yaaw非常容易:

    # git clone https://github.com/binux/yaaw.git
    # mv yaaw /var/www/html
    # chmod 777 /var/www/html/yaaw
    

    三个命令即安装成功。
    打开浏览器,地址栏输入:http://WSL服务器IP/yaaw

    yaaw界面
    使用方法和webui-aria2类似。

    优化aria2下载速度

    都说aria2的BT和磁力下载速度不给力,试了一下的确如此。解决办法就是在aira2.conf里加入bt-track:

    bt-tracker=udp://tracker.coppersurfer.tk:6969/announce,udp://tracker.open-internet.nl:6969/announce,udp://tracker.leechers-paradise.org:6969/announce,udp://tracker.opentrackr.org:1337/announce,udp://tracker.internetwarriors.net:1337/announce,udp://9.rarbg.to:2710/announce,udp://9.rarbg.me:2710/announce,udp://tracker.openbittorrent.com:80/announce,http://tracker3.itzmx.com:6961/announce,http://tracker1.itzmx.com:8080/announce,udp://exodus.desync.com:6969/announce,udp://tracker.torrent.eu.org:451/announce,udp://retracker.lanta-net.ru:2710/announce,udp://bt.xxx-tracker.com:2710/announce,http://tracker2.itzmx.com:6961/announce,udp://tracker.tiny-vps.com:6969/announce,udp://tracker.cyberia.is:6969/announce,udp://open.stealth.si:80/announce,udp://open.demonii.si:1337/announce,udp://explodie.org:6969/announce
    

    trackerslistbest传送门会经常更新最快的tracker,可以写个脚本自动更新它,留给读者自己研究吧。

    总结

    经过一番折腾,WSL服务器又变成了下载服务器。我可以随时从外网连接yaaw,添加下载任务,比如想看的视频,这样回家就可以看了。下载速度这方面,热门资源速度没的说,上面实测完全可以满速下载,但下载冷门资源就没那么给力了,要想完全取代迅雷,还需要继续优化。有高手修改源代码,将aria2的16线程限制改为无限,重新编译,据说效果很好,充分体现了Linux爱好者的折腾精神,大家自己去网上搜索相关资料吧。

    相关文章

      网友评论

        本文标题:和迅雷说再见!手把手教你如何让Windows 10 Ubuntu

        本文链接:https://www.haomeiwen.com/subject/ddiahctx.html