注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

從頭再來 Blog

一切將會如小生命的誕生一樣,從頭再來.....

 
 
 

日志

 
 

Ubuntu上安装 rtorrent [转]  

2008-04-15 00:23:45|  分类: Ubuntu |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
介紹:
在Linux 上跑bt 有很多軟體可以跑, 像是azureus 或是用 wine + bt 軟體都是可以運作,用過許多在Linux上bt軟體,還是推薦 rtorrent , 可以用ssh 文字介面就可以操作了也相當省資源 , 只是安裝比較麻煩一點,本篇介紹如何安裝rotrrent 並運作。


準備:需要準備下列的檔案自己編譯它
1.curl
2.sigc++-2.0  [然后执行apt-get install libssl-dev]
3.ncurses
4.libtorrent    [先安装 libsigc++ ]
5.rtorrent     [如果需要使用scgi_port 请用参数 ./configure --with-xmlrpc-c 编译]

安裝:
a.安裝 curl
# tar -zxvf curlxxxxxxx
# cd /curlxxx
# ./configure --prefix=/usr
# make; make install

如果在安裝 utorrent ./configure時,出現URL錯誤的話
# cd /usr/lib/pkgconfig
# vi /libcurl.pc
# #URL: <--將這行用#註解起來


b.安裝sigc++-2.0
# tar -zxvf libsigc++20-xxx
# cd libsigc++-2.0.17
# ./configure --prefix=/usr
# make; make install


c.安裝libtorrent
# apt-get install libssl-dev
# tar libtorrent
# cd libtorrent
# ./configure --prefix=/usr
# make; make install


注意: 在configure curl , sigc++-2.0 , libtorrent 時,多了個 --prefix=/usr 參數 ,因為避免當在編譯libtorrent時會找不到該curl , sigc 的檔案,所以在次多加個 --prefix=/usr 參數, 將該套件安裝在 /usr下

d.安裝rtorrent
# tar -zxvf rtorrent
# cd rtorrent
# ./configure
# make; make install



注:如果需要用 rutorrent 管理 rtorrent ,请安装 XMLRPC
       1) 下载 XMLRPC 后编译
         ./configure --disable-cplusplus
    
make
    
make install
       2) 在编译 rtorrent 时请加入 xmlrpc 参数
          ./configure --with-xmlrpc-c
     
make
     
make install
       3) 在/etc/apache2/httpd.conf中加入以下两行
           LoadModule scgi_module /usr/lib/apache2/modules/mod_scgi.so
           SCGIMount /RPC2 127.0.0.1:5000


執行:
#ldconfig <-把新的动态链接库搜索一下
# rtorrent <-執行rtorrent
如果要丟在背景執行則可以使用screen

# screen
# rtorrent

如果要返回前景時,在rtorrent畫面裡按下 ctrl+a 之後 ctrl+d, 則跳回前景, 之後回到rtorrent畫面則輸入
# screen -r

參數設定:
安裝完成後我們需要作一些配置工作,配置文件是安裝用戶家目錄下的.rtorrent.rc。這個文件默認是沒有的,請到這頁面,將示例的配置文件內容拷貝粘貼到.rtorrent.rc中,然後我們來編輯它。將前面的#刪除則是取消註解。
# cp rtorrent.rc ~/.rtorrent.rc
# vi ~/.rtorrent

最大和最小的種子連接數
# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 100


最大上傳數
# Maximum number of simultanious uploads per torrent.
#max_uploads = 15


上傳和下載速度限制 0:無限制
# Global upload and download rate in KiB. "0" for unlimited.
#download_rate = 0
#upload_rate = 0


下載檔案存放目錄
# Default directory to save the downloaded torrents.
#directory = ./


下載快取目錄
#session = ./session

torrent 檔存放目錄
#schedule = watch_directory,5,5,load_start=./watch/*.torrent

隨機port 範圍
#port_range = 6890-6999

下載檔案名使用 UTF-8 編碼
#encoding_list = UTF-8

設定rtorrent自動搬移已下載完成的檔案
on_finished = move_complete,"d.set_directory=~/Download/ ;execute=mv,-u,$d.get_base_path=,~/Download/"

如果出现如 "on_* command" 的错误,主要是rtorrent的版本不同导致。
## 適用 0.8.2 以前版本   
## on_finished =
move_complete,"d.set_directory=/mnt/share01/rtorrent/completed/
;execute=mv,-n,$d.get_base_path=,/mnt/share01/rtorrent/completed/"   

## 適用 0.8.3 以後版本   
system.method.set_key =
event.download.finished,move_complete,"execute=mv,-n,$d.get_base_path=,/mnt/share01/rtorrent/completed/
;d.set_directory=/mnt/share01/rtorrent/completed/"

这个参数和web配置以及远程管理有关
scgi_port = :5000 [这个参数需要rtorrent编译时支持XMLRPC]

下载完成后删除种子文件
schedule = watch_directory,10,10,"load_start=~/Download/watch_stuff/*.torrent,d.set_custom2=1"

上传缓存,每个种子10M,小内存用户请酌情修改

send_buffer_size = 10M

下载缓存,每个种子20M,小内存用户请酌情修改

receive_buffer_size = 20M



常用熱鍵:
1. 方向鍵 : ↑,↓,←,→
2. Torrent 開始下載 : Ctrl + S (Screen下用法為: Ctrl+ a + s)
3. Torrent 暫停下載 : Ctrl + D
4. Torrent 停止下載 : Ctrl + K
5. 清除Torrent下載列表 : [法1] 在停止狀態使用Ctrl + D, [法2] 在下載完成連續執行 Ctrl+D 二次
6. 限定最大上傳速度 : [增加]a / s / d [減少] z / x /c
7. check file hash : Ctrl + R
8. 離開rtorrent程式 : Ctrl+ q (Screen下用法為 : Ctrl+ a + q)

rtorrent.rc的配置范例:

min_peers = 30
max_peers = 200
#min_peers_seed = 10
#max_peers_seed = 50
max_uploads = 3
download_rate = 175
upload_rate = 15
directory = /home/xxxx/BT
on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/home/xxxx/BT/finished ;d.set_directory=/home/xxxx/BT/finished"
#on_finished = move_complete,"execute=mv,$d.get_base_path=/home/xxxx/BT/finished";d.set_director=/home/xxxx/BT/finished"
#on_finished = move_tied,"d.delete_tied="
#on_erase = move_complete,"execute=mv,-u$d.get_base_path=,/home/xxxx/BT/finished"
session = /home/xxxx/BT/.session
schedule = watch_directory,5,5,load_start=/home/xxxx/BT/*.torrent
#schedule = untied_directory,5,5,stop_untied=
schedule = low_diskspace,5,60,close_low_diskspace=50M
# schedule = ratio,60,60,"stop_on_ratio=200,200M,2000"
schedule = watch_direstory,10,10,"load_start=/home/xxxx/BT/*.torrent,d.set_custom2=1"
#schedule = watch_directory,10,10,"load_start=~/Download/watch_stuff/*.torrent,d.set_custom2=1"
#itch_directory,10,10,"load_start=~/Download/watch_stuff/*.torrent,d.set_custom2=1"p = 127.0.0.1
#ip = rakshasa.no
#bind = 127.0.0.1
#bind = rakshasa.no
port_range = 6999-6999
#port_random = no
check_hash = no
umask = 0000
use_udp_trackers = yes
#schedule = ip_tick,0,1800,ip=rakshasa
#schedule = bind_tick,0,1800,bind=rakshasa
dht = on
dht_port = 6778
peer_exchange = yes
#hash_read_ahead = 10
#hash_interval = 100
# send_buffer_size = 10M
# receive_buffer_size =50M
#hash_max_tries = 10
#encoding_list = zh_CN.UTF-8
encoding_list = UTF-8
#scgi_port = 127.0.0.1:5000

------------------------------  2010 年 2月 测试通过  -----------------------------

1) apt-get install php5 php5-xmlrpc libapache2-mod-scgi php5-cli
apt-get install php5-sqlite libapache2-mod-scgi rtorrent     
      XMLRPC-C 最好是自己编译, 源里的版本太低
     
http://xmlrpc-c.sourceforge.net/release.html
   编译过程:
       ./configure --disable-cplusplus
       make
       make install

2) 修改 /etc/apache2/sites-enable/000-default
在最前面加入:
        LoadModule scgi_module /usr/lib/apache2/modules/mod_scgi.so
        SCGIMount /RPC2 127.0.0.1:5000

 3)  service apache2 restart

 4)  在 /etc/apache2/mods-availabe 目录增加 scgi.conf
       内容为:
        SCGIMount /RPC2 127.0.0.1:5000

 5)  修改 /root/.rtorrent.rc
      在最后面加入:
         scgi_port = localhost:5000
         umask = 0002

具体参考: http://code.google.com/p/rtgui/wiki/ubuntu_rtgui

以上修改后不用再对 apache2.conf  和 httpd.conf 作出任何修改

如果需要加用户验证,请在/etc/apache2/httpd.conf里加入

<Location /ntorrent>    # 这里的目录名与下面的要相符
AuthName "Private"
AuthType Basic
AuthBasicProvider file
AuthUserFile /var/www/ntorrent/.htpasswd
Require valid-user
</Location>
** 然后生成验证文件
htpasswd -c /var/www/ntorrent/.htpasswd username

** 如果 rtorrentWeb 出现如下错误:
rTorrent is compiled with incorrect version of xmlrpc-c library, without i8 support. Version must be >= 1.11. Some functionality will be unavailable.

** 最后把 /tmp 的权限允许 www-data 读写
#chown www-data:www-data /tmp


增加开机启动 rtorrent

1) 先从这里下载 rtorrentInit.sh 这个文件,然后放入 /etc/init.d/ 目录下
http://libtorrent.rakshasa.no/raw-attachment/wiki/RTorrentCommonTasks/rtorrentInit.sh

#chmod 755 rtorrentInit.sh <-- 更改为可执行文件
#mv rtorrentInit.sh rtorrent <-- 改名为rtorrent

2) 加入到默认启动项目中
# update-rc.d rtorrent defaults

以上两步完成

-----------------------------------------------------------------------------------------


关于Samba的配置, 以下是例子:
# Samba config file
[global]
workgroup = NAT
server string = Ubuntu
interfaces = 10.0.0.1/24, eth0.1, br-lan, lo
security = share
map to guest = Bad Password
null passwords = Yes
guest account = root
log file = /opt/var/samba/log.%m
max log size = 10
name resolve order = wins bcast
socket options = SO_SNDBUF=8192 SO_RCVBUF=8192
load printers = No
dns proxy = No
ldap ssl = no
config file = /opt/etc/samba/smb.conf
create mask = 0771
force create mode = 0660
force directory mode = 0771
hosts allow = 10.0.0.0/16, 172.16.0.0/12, 192.168.1.0/16, localhost

[DISK 1]
comment = Public Folder Tree For Everyone
path = /mnt
public = yes
browseable = yes
writable = yes
printable = no
only guest = no


---------------------------------

Install xmlrpc-c

Download xmlrpc-c 1.11 from it's website. Once you have the package downloaded follow these instructions:

tar -zxvf xmlrpc-c-1.11.00.tgz
cd xmlrpc-c-1.11.00
./configure --disable-cplusplus
make
make install

Ok, you should have xmlrpc-c properly installed by now, let's follow with rtorrent. 2. Install rtorrent with xmlrpc support We are going to use the svn version, since it's the most updated one and probably the only one that works with wTorrent at the moment (stable and unestable releases have less xmlrpc methods and some parts of the interface might not work). Here's what we need to do:

mkdir rtorrent-svn
cd rtorrent-svn
svn co svn://rakshasa.no/libtorrent/trunk
svn up
cd trunk
cd libtorrent
./autogen.sh
./configure
make
make install
cd ../rtorrent
./autogen.sh
./configure --with-xmlrpc-c
make
make install

If everything went ok you should now have rtorrent with xmlrpc interface properly installed, now let's gonna configure it, edit your .rtorrent.rc and add the following line:

scgi_port = localhost:5000

------------------------------------------

Install the scgi gateway


Using mod_scgi for apache

Install and enable mod_scgi for apache (if you don't know how to do this refer to your distribution for instructions). Add the following to httpd.conf:

SCGIMount /RPC2 127.0.0.1:5000
After that add the following to httpd.conf
<Location /RPC2>
AuthName "Private"
AuthType Basic
AuthBasicProvider file
AuthUserFile /var/www/ntorrent/.htpasswd
Require valid-user
</Location>

For auth with apache you have to create a htpasswd file, which can be done this way:

htpasswd -c /var/www/ntorrent/.htpasswd username

In both cases your home.conf.php refering to rtorrent connection would look like:

define('RT_HOST','localhost');
define('RT_PORT',80); //Or 81 if using lighttpd.conf server.port option
define('RT_DIR','RPC2/');
define('RT_AUTH', true); // Set to false if you have not set up auth
define('RT_USER', 'user_name');
define('RT_PASSWD', 'password');


------------------------------------------

使用 rTorrentWeb 来管理


# apt-get install rtorrent screen
# cp /usr/share/doc/rtorrent/examples/rtorrent.rc ~/.rtorrent.rc
# nano ~/.rtorrent.rc
在最后加入以下命令

scgi_port = localhost:5000
umask = 0002

# screen rtorrent
检查一下界面中是否有 "XMLRPC initialized with x functions." 的字串
如果有继续以下的

# apt-get install apache2 php5-cli libapache2-mod-php5 php5-xmlrpc php5-sqlite libapache2-mod-scgi
# nano /etc/apache2/mods-available/scgi.conf
    加入以下命令  
    SCGIMount /RPC2 127.0.0.1:5000
# a2enmod php5    [检查php5的mod是否已经启用]
# a2enmod scgi [检查scgi的mod是否已经启用]
# /etc/init.d/apache2 restart

最后是安装 rTorrentWeb
# cd /tmp
# wget http://rtorrentweb.com/downloads/rTorrentWeb_1.0.tar.gz
#
tar zxf rTorrentWeb_1.0.tar.gz
#
cd rTorrentWeb_1.0
#
chmod +x install.php
#
./install.php
    安装流程会问你问题的, 基本上全部回车即可!
    注意: 如何使用 www-data 权限的话, 最后用 chown -R www-data:www-data /var/www/rtorrentweb
  评论这张
 
阅读(2112)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018