NPCHK Blog

路邊小博客(<ゝω・)☆

Ubuntu 18.04 (Bionic) 編譯rtorrent+RuTorrent (WebUI)安裝指南

教學通過測試於Ubuntu 18.04 (Bionic),支援IPv6。若想用於其他/不同版本的系統,請自行修改指令和軟件包名稱。
以下將編譯安裝rtorrent和libtorrenth的0.9.7 / 0.9.6版本:

  • 添加支援OpenSSL 1.1.0
  • 原生支援IPv6

其他系統編譯rtorrent教學:

Debian 7 (wheezy): https://npchk.info/debian7-install-rtorrent/

Debian 8 (Jessie): https://npchk.info/debian8-install-rtorrent/

Debian 9 (Stretch): https://npchk.info/debian9-install-rtorrent/

Ubuntu 16/17: https://npchk.info/ubuntu-install-rtorrent/

安裝編譯工具與依賴

apt-get update
apt-get install git build-essential automake libcppunit-dev libtool zlib1g-dev gawk libsigc++-2.0-dev libssl-dev libncurses5-dev libncursesw5-dev libcurl4-openssl-dev libxmlrpc-c++8-dev screen unzip

編譯rtorrent 0.9.7

從Github取得libtorrent 0.13.7 並添加支援OpenSSL1.1:

git clone https://github.com/rakshasa/libtorrent
cd libtorrent/
git config --global user.email "your@mail.com"
git config --global user.name "yourname"
git checkout v0.13.7
git cherry-pick 7b29b6b

編譯及安裝libtorrent:

./autogen.sh
./configure --disable-debug 
make -j$(nproc)
make install
cd ~

刷新動態庫:

ldconfig

從Github取得rtorrent 0.9.7:

git clone https://github.com/rakshasa/rtorrent
cd rtorrent
git checkout v0.9.7

編譯及安裝rtorrent:

./autogen.sh
./configure --with-xmlrpc-c --with-ncurses --enable-ipv6 --disable-debug
make -j$(nproc)
make install
cd ~

編譯rtorrent 0.9.6

從Github取得libtorrent feature-bind:

git clone https://github.com/rakshasa/libtorrent
cd libtorrent/
git checkout origin/feature-bind
git checkout 9eb9ba2

編譯及安裝libtorrent:

./autogen.sh
./configure --disable-debug 
make -j$(nproc)
make install
cd ~

刷新動態庫:

ldconfig

從Github取得rtorrent feature-bind:

git clone https://github.com/rakshasa/rtorrent
cd rtorrent
git checkout origin/feature-bind
git checkout b088c1c

編譯及安裝rtorrent:

./autogen.sh
./configure --with-xmlrpc-c --with-ncurses --enable-ipv6 --disable-debug
make -j$(nproc)
make install
cd ~

新增系統使用者

新增系統使用者,用於執行rtorrent和php-fpm
例如peter:

adduser peter

配置Nginx和PHP

安裝RuTorrent的網頁伺服器軟體:

apt-get install nginx-full php-fpm apache2-utils php7.2-cgi php7.2-cli php-geoip curl

禁用Nginx默認網站 新建站點配置文件:

rm /etc/nginx/sites-enabled/default
touch /etc/nginx/sites-available/rutorrent.conf
ln -s /etc/nginx/sites-available/rutorrent.conf /etc/nginx/sites-enabled/000-rutorrent.conf
nano /etc/nginx/sites-available/rutorrent.conf
輸入以下內容
server {
 
 server_name _;
 
 root /var/www;
 index index.html;
 
 location / {
 auth_basic "Restricted";
 auth_basic_user_file /etc/nginx/htpasswd;
 try_files $uri $uri/ =404;
 }
 
 location /RPC2 {
 scgi_pass 127.0.0.1:5000;
 include scgi_params;
 scgi_param SCRIPT_NAME /RPC2;
 }
 
 location ~ \.php$ {
 try_files $uri =404;
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include fastcgi_params;
 }
 
}

配置php-fpm7.2:

nano /etc/php/7.2/fpm/pool.d/www.conf
#修改參數#
user = peter
group = peter

listen = 127.0.0.1:9000

配置php-geoip:

nano /etc/php/7.2/fpm/php.ini
#加入一行:extension=geoip.so

重啟php7.2-fpm和Nginx以套用新設置:

systemctl restart php7.2-fpm
systemctl restart nginx

配置RuTorrent及Plugins

從Github取得RuTorrent:

wget https://github.com/Novik/ruTorrent/archive/master.zip
unzip master.zip

移動RuTorrent到Nginx的www目錄:

mv ruTorrent-master /var/www/rt

設置RuTorent需賬號及密碼登錄(例如peter):

htpasswd -c /etc/nginx/htpasswd peter

設置RuTorrent與PHP使用者peter的權限:

chown peter -R /var/www/rt/share

以下將配置RuTorrent的Plugins的依賴
配置Curl:

nano /var/www/rt/conf/config.php
#「"curl"  => '',」修改為「"curl"  => '/usr/bin/curl',」

「screenshots」Plugin需要ffmpeg:

apt-get install ffmpeg

「mediainfo」Plugin需要mediainfo:

apt-get install mediainfo

「unrar」Plugin需要unrar和rar:

apt-get install unrar rar

「Spectrogram」Plugin需要sox libsox-fmt-mp3:

apt-get install sox libsox-fmt-mp3

配置「Spectrogram」Plugin:

nano /var/www/rt/plugins/spectrogram/conf.php
#修改為$pathToExternals['sox'] = '/usr/bin/sox';

安裝「Autodl-irssi」 Plugin(第三方插件 非必要功能)
安裝irssi及依賴:

apt-get install irssi libarchive-zip-perl libnet-ssleay-perl libhtml-parser-perl libxml-libxml-perl libdigest-sha-perl libjson-perl libjson-xs-perl libxml-libxslt-perl php-xml

下載及安裝Autodl-irssi:

mkdir -p ~/.irssi/scripts/autorun
cd ~/.irssi/scripts
curl -sL http://git.io/vlcND | grep -Po '(?<="browser_download_url": ")(.*-v[\d.]+.zip)' | xargs wget --quiet -O autodl-irssi.zip
unzip -o autodl-irssi.zip
rm autodl-irssi.zip
cp autodl-irssi.pl autorun/
mkdir -p ~/.autodl
touch ~/.autodl/autodl.cfg

配置Autodl-irssi:

nano ~/.autodl/autodl.cfg
#輸入以下容內並設置Port及密碼,例如:
[options]
gui-server-port = 50000
gui-server-password = a577a5727fec6348

下載「Autodl-irssi」 Plugin到RuTorrent並設置PHP使用者peter的權限:

cd /var/www/rt/plugins/
git clone https://github.com/autodl-community/autodl-rutorrent.git autodl-irssi
cp autodl-irssi/_conf.php autodl-irssi/conf.php
chown -R peter:peter autodl-irssi

配置「Autodl-irssi」 Plugin:

nano autodl-irssi/conf.php
#填入剛才設置的Autodl-irssi Port及密碼

在Screen中啟動irssi:

screen -S autodl -fa -d -m irssi

配置rtorrent

**登錄至使用者peter,以下將使用peter操作**
創建rtorrent配置文件:

nano ~/.rtorrent.rc
內容(把*.*.*.*改為盒子的IPv4地址):
directory = /home/peter/Downloads
session = /home/peter/rtorrent/.sessions
 
schedule = watch_dir,5,5,"load.start=/home/peter/rtorrent/torrents/*.torrent, d.directory.set=/home/peter/rtorrent/incoming"
schedule = untied_directory,5,5,stop_untied=
schedule = untied_directory,5,5,close_untied=
schedule = untied_directory,5,5,remove_untied=
schedule = tied_directory,5,5,start_tied=
schedule = low_diskspace,10,30,close_low_diskspace=100M
 
upload_rate = 0
download_rate = 0
port_range = 34543-34543
port_random = no
encryption = allow_incoming,try_outgoing,enable_retry
dht = auto
check_hash = no
 
encoding_list = UTF-8
scgi_port = 127.0.0.1:5000
ip = *.*.*.*

創建下載、監控及記錄目錄:

mkdir ~/Downloads
mkdir ~/rtorrent/
mkdir ~/rtorrent/incoming
mkdir ~/rtorrent/.sessions
mkdir ~/rtorrent/torrents/

啟動rtorrent:

screen -S rt -fa -d -m rtorrent

安裝完成,訪問RuTorrent: http://YOURIPADDRESS/rt/

安裝資訊

下載文件的保存目錄/位置 = /home/peter/Downloads
監控目錄 = /home/peter/rtorrent/torrents/
Nginx根目錄 = /var/www/
訪問rtorrent命令行界面: screen -r rtorrent
訪問irssi界面:screen -r autodl







  1. iloft 說:

    可以尝试把Nginx 替换成Caddy 配置起来更简单~~

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *