VPS上用debian装transmission教程

1. 前言:
原来都是在Centos上装Transmission挂PT的,这两天在折腾我的VPS,分别试着在Centos和Debian上安装了rtorrent+rutorrent,结果发现rtorrent和transmission相比,并不是很稳定,经常崩溃,虽然可以写脚本定时检查重启,但每次重启都会重新hash文件,问题多多,所以个人以为还是transmission比较合适个人安装使用,之所以rtorrent很多seedbox在用,主要是它比较容易支持多用户,适合多人共享。最终决定还是装回transmission,因为reload的OS是debian,所以也不准备换成centos,于是就有了这篇教程。

2.升级系统
我这里reload的是debian-5.0x86的,不同的版本有可能出现的错误不一样,有问题可以跟贴问,为了方便,我这里都是用root登录安装的
首先升级系统:apt-get update

apt-get upgrade
复制代码结果第一条命令就有错误:GPG error: http://ftp.de.debian.org lenny/updates Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY AED4B06F473041FA
复制代码你不能忽略这这个,不然下面安装必要库文件的时候会有些库装不上,要解决这个错误,输入下面命令apt-get install debian-archive-keyring
复制代码然后重新输入上面两条命令,这次就没有错误了,你需要等几分钟等这个过程结束,这取决于你的VPS

3.安装Transmission
先安装必要的库文件这个可以在transmission的网站找到,所以很简单,直接输入apt-get install build-essential automake make autoconf libtool pkg-config libcurl4-openssl-dev intltool libxml2-dev libgtk2.0-dev libnotify-dev libglib2.0-dev libevent-dev
复制代码下载transmission,我这里下的是2.13,并不是最新版,因为最新的版本不在我常去PT的允许客户端列表里,你安装的时候也可以看看你所混的PT的FAQ,然后下载合适的版本,不然被Ban了不要怪我wget http://download.m0k.org/transmission/files/transmission-2.13.tar.bz2

tar xvjf transmission-2.13.tar.bz2

cd transmission-2.13

./configure
复制代码在./configure那一步出现错误:configure: error: libevent 1.4.9 or higher not found!
复制代码因此下载安装所需要的libevent版本:wget http://ftp.us.debian.org/debian/pool/main/libe/libevent/libevent-1.4-2_1.4.13-stable-1_i386.deb

wget http://ftp.us.debian.org/debian/pool/main/libe/libevent/libevent-core-1.4-2_1.4.13-stable-1_i386.deb

wget http://ftp.us.debian.org/debian/pool/main/libe/libevent/libevent-extra-1.4-2_1.4.13-stable-1_i386.deb

wget http://ftp.us.debian.org/debian/pool/main/libe/libevent/libevent-dev_1.4.13-stable-1_i386.deb

dpkg -i *.deb
复制代码然后继续./configure

make

make install
复制代码


4.安装Transmission的启动,停止脚本
脚本在transmission网站有现成的,为了方便起见,我还是把它放在这里
#! /bin/sh

### BEGIN INIT INFO

# Provides: transmission-daemon

# Required-Start: networking

# Required-Stop: networking

# Default-Start: 2 3 5

# Default-Stop: 0 1 6

# Short-Description: Start the transmission BitTorrent daemon client.

### END INIT INFO



# Original Author: Lennart A. JÃŒtte, based on Rob Howell's script

# Modified by Maarten Van Coile & others (on IRC)



# Do NOT "set -e"



#

# ----- CONFIGURATION -----

#

# For the default location Transmission uses, visit:

# http://trac.transmissionbt.com/wiki/ConfigFiles

# For a guide on how set the preferences, visit:

# http://trac.transmissionbt.com/wiki/EditConfigFiles

# For the available environement variables, visit:

# http://trac.transmissionbt.com/wiki/EnvironmentVariables

#

# The name of the user that should run Transmission.

# It's RECOMENDED to run Transmission in it's own user,

# by default, this is set to 'transmission'.

# For the sake of security you shouldn't set a password

# on this user

USERNAME=transmission





# ----- *ADVANCED* CONFIGURATION -----

# Only change these options if you know what you are doing!

#

# The folder where Transmission stores the config & web files.

# ONLY change this you have it at a non-default location

#TRANSMISSION_HOME="/var/config/transmission-daemon"

#TRANSMISSION_WEB_HOME="/usr/share/transmission/web"

#

# The arguments passed on to transmission-daemon.

# ONLY change this you need to, otherwise use the

# settings file as per above.

#TRANSMISSION_ARGS=""





# ----- END OF CONFIGURATION -----

#

# PATH should only include /usr/* if it runs after the mountnfs.sh script.

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

DESC="bittorrent client"

NAME=transmission-daemon

DAEMON=$(which $NAME)

PIDFILE=/var/run/$NAME.pid

SCRIPTNAME=/etc/init.d/$NAME



# Exit if the package is not installed

[ -x "$DAEMON" ] || exit 0



# Read configuration variable file if it is present

[ -r /etc/default/$NAME ] && . /etc/default/$NAME



# Load the VERBOSE setting and other rcS variables

[ -f /etc/default/rcS ] && . /etc/default/rcS



#

# Function that starts the daemon/service

#



do_start()

{

# Export the configuration/web directory, if set

if [ -n "$TRANSMISSION_HOME" ]; then

export TRANSMISSION_HOME

fi

if [ -n "$TRANSMISSION_WEB_HOME" ]; then

export TRANSMISSION_WEB_HOME

fi



# Return

# 0 if daemon has been started

# 1 if daemon was already running

# 2 if daemon could not be started

start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \

--exec $DAEMON --background --test -- -f $TRANSMISSION_ARGS > /dev/null \

|| return 1

start-stop-daemon --chuid $USERNAME --start --pidfile $PIDFILE --make-pidfile \

--exec $DAEMON --background -- -f $TRANSMISSION_ARGS \

|| return 2

}



#

# Function that stops the daemon/service

#

do_stop()

{

# Return

# 0 if daemon has been stopped

# 1 if daemon was already stopped

# 2 if daemon could not be stopped

# other if a failure occurred

start-stop-daemon --stop --quiet --retry=TERM/10/KILL/5 --pidfile $PIDFILE --name $NAME

RETVAL="$?"

[ "$RETVAL" = 2 ] && return 2



# Wait for children to finish too if this is a daemon that forks

# and if the daemon is only ever run from this initscript.

# If the above conditions are not satisfied then add some other code

# that waits for the process to drop all resources that could be

# needed by services started subsequently. A last resort is to

# sleep for some time.



start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON

[ "$?" = 2 ] && return 2



# Many daemons don't delete their pidfiles when they exit.

rm -f $PIDFILE



return "$RETVAL"

}



case "$1" in

start)

echo "Starting $DESC" "$NAME..."

do_start

case "$?" in

0|1) echo " Starting $DESC $NAME succeeded" ;;

*) echo " Starting $DESC $NAME failed" ;;

esac

;;

stop)

echo "Stopping $DESC $NAME..."

do_stop

case "$?" in

0|1) echo " Stopping $DESC $NAME succeeded" ;;

*) echo " Stopping $DESC $NAME failed" ;;

esac

;;

restart|force-reload)

#

# If the "reload" option is implemented then remove the

# 'force-reload' alias

#

echo "Restarting $DESC $NAME..."

do_stop

case "$?" in

0|1)

do_start

case "$?" in

0|1) echo " Restarting $DESC $NAME succeeded" ;;

*) echo " Restarting $DESC $NAME failed: couldn't start $NAME" ;;

esac

;;

*)

echo " Restarting $DESC $NAME failed: couldn't stop $NAME" ;;

esac

;;

*)

echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2

exit 3

;;

esac
复制代码这个脚本文件需要作为transmission-daemon放在/etc/init.d/下面,输入以下命令:
vi /etc/init.d/transmission-daemon
复制代码按i,然后把上面这个脚本粘帖进去,按ESC,然后按冒号:,输入wq,按回车,文件就建立好了

接下来更改文件的权限并使它在启动的时候可以自动执行:
chmod +x /etc/init.d/transmission-daemon

chown root:root /etc/init.d/transmission-daemon

update-rc.d transmission-daemon defaults
复制代码下来新建一个用户运行transmission,这里用的用户名是transmission,当然你也可以用其他的,不过记得要更改脚本了的USERNAME与之对应

useradd -mr transmission

chmod g+rwx /home/transmission/
复制代码
建立transmission的下载目录并设定权限:

mkdir -p /home/transmission/Downloads/

chown -R transmission.transmission /home/transmission/Downloads/

chmod g+w /home/transmission/Downloads/
复制代码接下来就可以启动transmission了:
/etc/init.d/transmission-daemon start
复制代码
transmission启动后就自动会在/home/transmission/.config/transmission-daemon下生成settings.json文件,不过在你更改设置之前必须先停止transmission:
/etc/init.d/transmission-daemon stop
复制代码这样你就可以开始更改设置了:
vi /home/transmission/.config/transmission-daemon/settings.json
复制代码按i以后就可以开始编辑了,至于参数什么意思请参考transmission的网站,改完后按ESC, 按冒号:,输入wq回车存盘
为了方便你在家里的电脑上用Transmission Remote GUI的连上去管理,下面的设置你必须更改:

"rpc-whitelist-enabled": false - 默认是true,要改为false

“rpc-password": "密码",

"rpc-username": "用户名",

上面的密码和用户名你可以自己指定
复制代码
从新启动transmission,新的设置就会生效:
/etc/init.d/transmission-daemon start
复制代码现在你可以下载并安装Transmission Remote GUI,在GUI的options输入VPS的IP地址,rpc的端口(默认是9091,你可以在settings.json中改成其他的),你的用户名和密码,就可以连到你VPS上的transmission了
Transmission Remote GUI的下载地址:
http://transmisson-remote-gui.googlecode.com/files/transgui-2.2-setup.exe
复制代码另外如果你用Android的手机,可以在菜市场搜索安装Transdroid,它可以很方便的在手机上管理transmission,也可以在手机上下载torrent,通过它传到vps的transmission里进行下载,非常方便

至此transmission在debian的安装就告一段落了,下来有时间我会写一下如何通过rss和irc自动下载torrent并传给transmission进行下载