前提安装好 Nginx 及 PHP

一、rTorrent 安装及配置

1、安装:apt update && apt install rtorrent mediainfo subversion ca-certificates git sox unrar unzip ffmpeg -y

2、创建 rtorrent.rc 配置文件:

nano /root/.rtorrent.rc

# 设定默认保存 torrents 的目录
directory.default.set = /home

# 默认会话目录. 确保你没有同时运行使用相同会话目录的 rTorrent 程序
session.path.set = /www/rutorrent/.session

# 全局最大上传和下载速率(单位:KiB),"0"表示无限制
throttle.global_down.max_rate.set_kb = 0
throttle.global_up.max_rate.set_kb = 0

# 连接到每个种子的最大和最小节点(用户/Peer)数
throttle.min_peers.normal.set = 100
throttle.max_peers.normal.set = 1000

# 同上,但仅针对已完成的种子(-1 表示与下载中的种子一致)
throttle.min_peers.seed.set = -1
throttle.max_peers.seed.set = -1

# 同时下载和上传插槽的最大数量
throttle.max_downloads.global.set = 1000
throttle.max_uploads.global.set = 1000

# 每个种子最大同时上传数量
throttle.max_uploads.set = 150

# 用于监听的端口范围
network.port_range.set = 51001-51250

# 从上方的监听端口范围中随机选择开放端口
network.port_random.set = yes

# 当所有trackers失效情况下,为trackerless torrents开启DHT支持 可选值 
# "disable"(完全禁止),"off"(不启动),"auto"(按需要启动或停止),"on"(开启) 默认值为 
# "off",若要使DHT工作,会话(Session)目录必须被定义
dht.mode.set = auto

# DHT网络所使用的UDP端口
dht.port.set = 6881

# 启用peer交换 (用于那些没有被标记为私有的torrent,一般指PT)
protocol.pex.set = yes

# 设置客户端是否尝试连接 UDP trackers
trackers.use_udp.set = yes

# 访问地址及端口
scgi_port = 127.0.0.1:5000

# 加密选项,设为 none(默认情况)或下面的任何一个: allow_incoming, try_outgoing, require, 
# require_RC4, enable_retry, prefer_plaintext 
# 如下例中的值表示允许入站连接加密,出站连接开始时以非加密方式进行, 
# 如行不通则以加密方式进行重试,在加密握手后,优先选择将纯文本RC4方式加密
protocol.encryption.set = allow_incoming,enable_retry,prefer_plaintext

# 对完成的种子进行hash校验。在直到导致磁盘空间不足的BUG被上报修复之前都可能是很有用的
pieces.hash.on_completion.set = no

# 当磁盘空间不足时停止下载
schedule2 = low_diskspace,5,60,close_low_diskspace=100M

# 最大打开文件数
network.max_open_files.set = 4096

# 最大打开HTTP连接数
network.http.max_open.set = 512

# 最大使用内存
pieces.memory.max.set = 1500M
network.xmlrpc.size_limit.set = 4M

encoding.add = utf8

3、创建 rtorrent.service:

nano /etc/systemd/system/rtorrent.service

[Unit]
Description=rTorrent
After=network-online.target

[Service]
User=root
ExecStart=/bin/sh -c "/usr/bin/rtorrent -s /www/rutorrent/.session -o session=/www/rutorrent/.session -o system.daemon.set=true"
WorkingDirectory=~
Restart=on-failure

[Install]
WantedBy=multi-user.target

设置开机启动:systemctl enable rtorrent

二、ruTorrent 安装及配置

1、用 git 和 svn 把 ruTorrent 和所有的插件拖回本地:

mkdir /www
cd /www
git clone https://github.com/Novik/ruTorrent.git rutorrent
rm -r rutorrent/plugins
svn checkout https://github.com/Novik/ruTorrent/trunk/plugins rutorrent/plugins

2、添加 path:

1、nano /www/rutorrent/conf/config.php

# 此处为默认保存 torrents 的目录
$topDirectory = '/home';

$pathToExternals = array(
    "php"    => '/usr/bin/php7.3',
    "curl"    => '/usr/bin/curl',
    "gzip"  => '/usr/bin/gzip',
    "id"    => '/usr/bin/id',
    "stat"  => '/usr/bin/stat',
    "pgrep" => '/usr/bin/pgrep',
    "python" => '/usr/bin/python3',
);

2、nano /www/rutorrent/plugins/spectrogram/conf.php

$pathToExternals['sox'] = '/usr/bin/sox';

ps:使用 which 命令查看文件所在路径

3、按需添加插件

rm -f /www/rutorrent/conf/plugins.ini
nano /www/rutorrent/conf/plugins.ini

;; Plugins' permissions.
;; If flag is not found in plugin section, corresponding flag from "default" section is used.
;; If flag is not found in "default" section, it is assumed to be "yes".
;;
;; For setting individual plugin permissions you must write something like that:
;;
;; [ratio]
;; enabled = yes            ;; also may be "user-defined", in this case user can control plugin's state from UI
;; canChangeToolbar = yes
;; canChangeMenu = yes
;; canChangeOptions = no
;; canChangeTabs = yes
;; canChangeColumns = yes
;; canChangeStatusBar = yes
;; canChangeCategory = yes
;; canBeShutdowned = yes

[default]
enabled = user-defined
canChangeToolbar = yes
canChangeMenu = yes
canChangeOptions = yes
canChangeTabs = yes
canChangeColumns = yes
canChangeStatusBar = yes
canChangeCategory = yes
canBeShutdowned = yes

[_cloudflare]
enabled = no

[_getdir]
enabled = yes

[_noty]
enabled = no

[_noty2]
enabled = yes

[_task]
enabled = yes

[autotools]
enabled = user-defined

[check_port]
enabled = no

[chunks]
enabled = user-defined

[cookies]
enabled = user-defined

[cpuload]
enabled = user-defined

[create]
enabled = user-defined

[data]
enabled = user-defined

[datadir]
enabled = yes

[diskspace]
enabled = user-defined

[edit]
enabled = user-defined

[erasedata]
enabled = user-defined

[extratio]
enabled = user-defined

[extsearch]
enabled = user-defined

[feeds]
enabled = no

[filedrop]
enabled = user-defined

[geoip]
enabled = user-defined

[history]
enabled = no

[httprpc]
canBeShutdowned = no

[ipad]
enabled = user-defined

[loginmgr]
enabled = no

[lookat]
enabled = no

[mediainfo]
enabled = yes

[ratio]
enabled = user-defined

[retrackers]
enabled = no

[rpc]
enabled = no

[rss]
enabled = user-defined

[rssurlrewrite]
enabled = no

[rutracker_check]
enabled = no

[scheduler]
enabled = user-defined

[screenshots]
enabled = yes

[seedingtime]
enabled = yes

[show_peers_like_wtorrent]
enabled = user-defined

[source]
enabled = yes

[spectrogram]
enabled = yes

[theme]
enabled = yes

[throttle]
enabled = user-defined

[tracklabels]
enabled = user-defined

[trafic]
enabled = user-defined

[unpack]
enabled = user-defined

[uploadeta]
enabled = yes

[xmpp]
enabled = yes

三、Nginx 配置

Nginx 添加 www:groupadd www && useradd -g www www
赋予 rutorrent 用户组和权限:chown -R www:www /www/rutorrent
在线 htpasswd 生成器:https://tool.oschina.net/htpasswd,生成结果保存为 rt_passwd

server {
    listen 443 http2 ssl;
    server_name example.com;
    ssl_certificate /www/ssl/example.pem;
    ssl_certificate_key /www/ssl/example.key;
    charset utf-8;
    root /www/rutorrent;
    index index.php index.html index.htm;

    location /RPC2 {
        scgi_pass 127.0.0.1:5000;
    }

    location / {
        auth_basic "Enter your password to continue";
        auth_basic_user_file /etc/nginx/conf.d/rt_passwd;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

server{
   listen 80;
   server_name example.com;
   rewrite ^(.*)$ https://$host$1  permanent;
}
Last modification:August 2nd, 2020 at 06:21 pm
如果觉得我的文章对你有用,请随意赞赏