搭建Aria2+Aria2Web管理面板

更好的閱讀體驗歡迎訪問博客搭建Aria2+Aria2Web管理面板php

前言

因爲想使用網盤的離線下載功能,須要搭建aria2,特此記錄。html

1、編譯安裝Aira2

安裝wgetlinux

yum install wget

安裝編譯器nginx

yum install gcc gcc-c++

建立aria2目錄c++

mkdir -p /home/aria2/downloads
cd /home/aria2

下載並解壓aira2git

wget https://github.com/aria2/aria2/releases/download/release-1.33.1/aria2-1.33.1.tar.gz
tar -xzvf aria2-1.33.1.tar.gz

編譯安裝aria2github

cd aria2-1.33.1
./configure
make
cd src 
cp aria2c /usr/bin

安裝完成後執行web

aria2c -v

出現"aria2 version 1.33.1"等代碼則安裝成功vim

接下來設置aria2c瀏覽器

touch /home/aria2/aria2.session
vim /home/aria2/aria2.conf

內容爲

## 文件保存相關 ##

# 文件的保存路徑(可以使用絕對路徑或相對路徑), 默認: 當前啓動位置
dir=/home/aria2/downloads
# 啓用磁盤緩存, 0爲禁用緩存, 需1.16以上版本, 默認:16M
disk-cache=32M
# 文件預分配方式, 能有效下降磁盤碎片, 默認:prealloc
# 預分配所需時間: none < falloc ? trunc < prealloc
# falloc和trunc則須要文件系統和內核支持
# NTFS建議使用falloc, EXT3/4建議trunc, MAC 下須要註釋此項
file-allocation=trunc
# 斷點續傳
continue=true

## 下載鏈接相關 ##

# 最大同時下載任務數, 運行時可修改, 默認:5
max-concurrent-downloads=10
# 同一服務器鏈接數, 添加時可指定, 默認:1
max-connection-per-server=10
# 最小文件分片大小, 添加時可指定, 取值範圍1M -1024M, 默認:20M
# 假定size=10M, 文件爲20MiB 則使用兩個來源下載; 文件爲15MiB 則使用一個來源下載
min-split-size=20M
# 單個任務最大線程數, 添加時可指定, 默認:5
split=10
# 總體下載速度限制, 運行時可修改, 默認:0
max-overall-download-limit=0
# 單個任務下載速度限制, 默認:0
max-download-limit=0
# 總體上傳速度限制, 運行時可修改, 默認:0
max-overall-upload-limit=500K
# 單個任務上傳速度限制, 默認:0
max-upload-limit=100K
# 禁用IPv6, 默認:false
disable-ipv6=false

## 進度保存相關 ##

# 從會話文件中讀取下載任務
input-file=/home/aria2/aria2.session
# 在Aria2退出時保存`錯誤/未完成`的下載任務到會話文件
save-session=/home/aria2/aria2.session
# 定時保存會話, 0爲退出時才保存, 需1.16.1以上版本, 默認:0
save-session-interval=60
# 強制保存會話, 即便任務已經完成, 默認:false
# 較新的版本開啓後會在任務完成後依然保留.aria2文件
force-save=true
bt-hash-check-seed=true
bt-seed-unverified=true
bt-save-metadata=true

## RPC相關設置 ##

# 啓用RPC, 默認:false
enable-rpc=true
# 容許全部來源, 默認:false
rpc-allow-origin-all=true
# 容許非外部訪問, 默認:false
rpc-listen-all=true
# 事件輪詢方式, 取值:[epoll, kqueue, port, poll, select], 不一樣系統默認值不一樣
event-poll=select
# RPC監聽端口, 端口被佔用時能夠修改, 默認:6800
rpc-listen-port=6800
# 設置的RPC受權令牌, v1.18.4新增功能, 取代 --rpc-user 和 --rpc-passwd 選項
rpc-secret=123456

## BT/PT下載相關 ##

# 當下載的是一個種子(以.torrent結尾)時, 自動開始BT任務, 默認:true
follow-torrent=true
# BT監聽端口, 當端口被屏蔽時使用, 默認:6881-6999
listen-port=19999
# 單個種子最大鏈接數, 默認:55
bt-max-peers=100
# 打開DHT功能, PT須要禁用, 默認:true
enable-dht=true
# 打開IPv6 DHT功能, PT須要禁用
enable-dht6=false
# DHT網絡監聽端口, 默認:6881-6999
dht-listen-port=6881-6999
# 本地節點查找, PT須要禁用, 默認:false
bt-enable-lpd=true
# 種子交換, PT須要禁用, 默認:true
enable-peer-exchange=true
# 每一個種子限速, 對少種的PT頗有用, 默認:50K
bt-request-peer-speed-limit=50K
# 客戶端假裝, PT須要
peer-id-prefix=-TR2770-
user-agent=Transmission/2.77
# 當種子的分享率達到這個數時, 自動中止作種, 0爲一直作種, 默認:1.0
seed-ratio=0.2
# BT校驗相關, 默認:true
bt-hash-check-seed=true
# 繼續以前的BT任務時, 無需再次校驗, 默認:false
bt-seed-unverified=true
# 保存磁力連接元數據爲種子文件(.torrent文件), 默認:false
bt-save-metadata=false
#強制加密, 防迅雷必備
bt-require-crypto=true
#添加額外tracker#
#bt-tracker=

其中RPC相關設置中的祕鑰在ariang管理面板須要填寫,默認123456,完成後到服務器安全組開放6800端口

執行命令使配置生效

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

設置開機自啓動

vim /etc/rc.d/rc.local

在最後添加

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

2、編譯安裝Nginx Web服務器

安裝nginx依賴

yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel

下載並解壓nginx

cd /usr/local/src
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz

編譯安裝nginx

cd nginx-1.18.0
./configure --prefix=/usr/local/nginx
make
make install

建立nginx帳號

groupadd nginx
useradd -M -g nginx -s /sbin/nologin nginx
cd /usr/local/nginx/conf
vim nginx.conf

將第一行"#user nobody"改成

user nginx nginx

ESC+:wq+Enter保存並退出

啓動nginx

/usr/local/nginx/sbin/nginx

瀏覽器輸入服務器公網IP,出現Welcome to nginx!則成功

將nginx添加到系統服務

vim /usr/lib/systemd/system/nginx.service

內容爲

[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network.target remote-fs.target nss-lookup.target
  
[Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
  
[Install]
WantedBy=multi-user.target

結束nginx進程

lsof -i:80
kill -9 進程號

執行

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

經過系統服務啓動nginx

systemctl start nginx

設置爲開機啓動

systemctl enable nginx

重啓服務器後在瀏覽器輸入公網IP查看是否成功

3、搭建Aria2Ng Web面板

建立站點目錄

mkdir /home/www
mkdir /home/www/aria2ng

下載並解壓aria2ng

cd /home/www/aria2ng
wget https://github.com/mayswind/AriaNg/releases/download/1.1.6/AriaNg-1.1.6.zip
yum install uzip
unzip AriaNg-1.1.6.zip

建立nginx配置文件

mkdir /usr/local/nginx/vhost
vim /usr/local/nginx/vhost/vhost_aria2ng.conf

內容爲

server {
        listen       6801;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   /home/www/aria2ng;
            index  index.html index.htm index.php;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
vim /usr/local/nginx/conf/nginx.conf

在http{}代碼塊最後添加

include /usr/local/nginx/vhost/*.conf;

在服務器開放6801端口後重啓nginx

systemctl restart nginx

完成後在瀏覽器輸入服務器公網IP:6801,在「AriaNg設置--PRC(localhost:6800)--Aria2 PRC 祕鑰」填寫祕鑰,刷新頁面便可

參考文章:

CentOS7將Nginx添加系統服務的方法步驟

linux編譯安裝aria2,遠程下載設置

Liunx Mint下載方案Aria二、web面板AriaNG搭建

相關文章
相關標籤/搜索