[MT]主机上安装svn客户端

有了svn,就可以方便的获取一些程序的源码了,所以我要在MT主机上安装,注意只是客户端,并非架设svn服务器。

svn目前的最新版是1.4.4,我参考[shunz的Apache+Subversion安装笔记](http://www.shunz.net/2007/02/apache-mysql-subversion.html),从http://www.axint.net/apache/apr/binaries/rpm/i386/下载了apr-1.2.8-1.i386.rpmapr-util-1.2.8-1.i386.rpm(新版svn需要apr版本0.9.7以上,而且是必需),可是rpm -U apr*.rpm的时候系统却提示依赖性错误:

warning: apr-1.2.8-1.i386.rpm: V3 DSA signature: NOKEY, key ID 751d7f27
error: Failed dependencies:
        libpq.so.3 is needed by apr-util-1.2.8-1.i386
        libapr-0.so.0 is needed by (installed) httpd-2.0.52-32.3.ent.centos4.i386
        libapr-0.so.0 is needed by (installed) mod_perl-1.99_16-4.5.i386
        libapr-0.so.0 is needed by (installed) subversion-1.1.4-2.ent.i386
        libapr-0.so.0 is needed by (installed) subversion-perl-1.1.4-2.ent.i386
        apr = 0.9.4-24.5.c4.2 is needed by (installed) apr-devel-0.9.4-24.5.c4.2.i386
        libaprutil-0.so.0 is needed by (installed) httpd-2.0.52-32.3.ent.centos4.i386
        libaprutil-0.so.0 is needed by (installed) mod_perl-1.99_16-4.5.i386
        libaprutil-0.so.0 is needed by (installed) subversion-1.1.4-2.ent.i386
        libaprutil-0.so.0 is needed by (installed) subversion-perl-1.1.4-2.ent.i386
        apr-util = 0.9.4-21 is needed by (installed) apr-util-devel-0.9.4-21.i386

(rpm和redhat系列不熟悉)看了半天才搞懂,rpm -U是升级,而系统中的现有apr 0.9.4版本被其他软件比如apache、mod_perl等依赖,升级过去可能就破坏依赖性关系了。如果rpm -i的话应该是安装新版本,不知道centos上不同的软件版本能否共存,考虑到合租服务器的稳定性,还是决定按照MT客服的建议,安装svn的旧版本1.3.2:

wget http://subversion.tigris.org/downloads/subversion-1.3.2.tar.gz
gunzip subversion-1.3.2.tar.gz
tar -xvf subversion-1.3.2.tar
cd subversion-1.3.2
./configure && make && make install

顺利完成,也可以下载[其他形式的源码包](http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=6781&expandFolder=6781&folderID=0),然后再配置svn到用户的chroot环境当中,大家就都能用了。

配置svn到chroot环境的时候需要的包很多,ldd就行,另外如果想checkout https形式的仓库,还要配置/dev下的随机数生成器:

# mknod /var/www/vhosts/chroot/dev/urandom c 1 9

不然会出错:

SSL negotiation failed: SSL disabled due to lack of entropy

基本可用了,不过checkout含有中文名称文件的仓库时,又会遇到如下错误:

svn: Can't recode string

基本可以确定是svn无法转换字符集的原因([参考](http://readlist.com/lists/subversion.tigris.org/users/0/56.html)),再进一步查找原因,发现竟然是centos的系统默认字符集不是utf8的,于是更改/etc/sysconfig/i18n,设定为如下内容:

LANG="en_US.UTF-8"
SUPPORTED="en_US.UTF-8:en_US:en"
SYSFONT="latarcyrheb-sun16"
#LANG="C"

重启服务器,root用户可以使用中文了,普通用户还不行,需要把/usr/lib/locale/en_US.utf8/配置到chroot环境中去,然后在普通用户的$HOME目录下的.bashrc或者.bash_profile文件中加入一句export LANG=en_US.UTF-8,重新登录后就可以啦,UTF8万岁!

仍然剩余一个诡异的问题,root用户无法使用https形式的仓库:

svn: SSL is not supported

注意普通用户是可以使用的,怎么回事?用whereis发现服务器上有两个svn文件:

# whereis svn
svn: /usr/bin/svn /usr/local/bin/svn /usr/share/man/man1/svn.1.gz

分别查看其版本:

# /usr/bin/svn --version
svn, version 1.1.4 (r13838)
   compiled Aug 21 2005, 20:56:55
...
* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
  - handles 'http' schema
  - handles 'https' schema

# /usr/local/bin/svn --version
svn, version 1.3.2 (r19776)
   compiled Aug  9 2007, 16:51:43
...
* ra_dav : Module for accessing a repository via WebDAV (DeltaV) protocol.
  - handles 'http' scheme

合着我编译了半天都是徒劳啊,服务器上早就有了svn了,我明明记得是没有啊,难道是客服在装编译套件[developer’s tools package](http://kb.mediatemple.net/article.php?id=240)时给装上了?可看了那个包列表里也没有啊?依然诡异,忙活半天还少编译了个SSL选项进来。

也许是MT客服给装编译套件的时候,为了自己用着方便,顺手放过来一个svn?谁还有新租的DV 3.0主机麻烦确认一下好了。

参考(部分是安装svn服务器的):

  • [Apache chroot: the mod security way](http://gentoo-wiki.com/Apache_chroot:_the_mod_security_way)
  • [Installing Subversion on a MediaTemple DV 3.0 Virtual Server](http://blog.hellm.com/post/5)
  • [setup svn server on media temple dv or centos with plesk](http://elsid.net/2007/05/07/setup-svn-server-on-media-temple-dv-or-centos-with-plesk/)
  • [Installing Subversion with Plesk 8.0/ CentOs 4.3 as Subdomain](http://alexle.net/archives/138)
  • [CentOS Wiki – HowTos – Subversion](http://wiki.centos.org/HowTos/Subversion)

关于svn字符集错误以及centos字符集问题的参考:

  • [SWsoft > Forums > Chroot SVN Addition Problems](http://forum.swsoft.com/showthread.php?threadid=35827)
  • [www.centos.org > forum > How to enable UTF8 support?](http://www.centos.org/modules/newbb/viewtopic.php?topic_id=7484&forum=27&post_id=23394#forumpost23394)
  • [www.centos.org > forum > Default Character Set / Locale](http://www.centos.org/modules/newbb/viewtopic.php?topic_id=3823&forum=27&post_id=10958#forumpost10958)
  • [CentOS AS 3.8+4.4 不编译内核为IPTABLES添加模块](http://bbs.chinaunix.net/viewthread.php?tid=863748&page=1)
  • [centos 5 或者 rhel5 i18n问题](http://linux.chinaunix.net/bbs/viewthread.php?tid=899451&page=1)

带SSL编译svn的一些资料:

  • [Re: SSL is not supported](http://svn.haxx.se/users/archive-2005-07/0997.shtml)
  • [Installing the Subversion Client with SSL Support on Linux](http://www.bernzilla.com/item.php?id=651)
  • [SSL is not supported](http://archives.devshed.com/forums/development-94/ssl-is-not-supported-1177066.html)

Leave a Reply

Your email address will not be published. Required fields are marked *