hengheng123456789

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  297 Posts :: 68 Stories :: 144 Comments :: 0 Trackbacks
 

SVN Beginning

http://blog.doesite.net/read.php?save_215

1.安装 subversion

# apt-get install subversion subversion-tools

创建一个新的储存库:

#svnadmin create /svn/repository

/svn目录创建一个新的空储存库,数据储存方式默认采用Berkeley DB

导入你的源码:

# svn import /svn/repository file:///data/svn/ldap

/data/ldap整个目录导入到储存库中的repository目录中,储存库的repository目录会自动创建。

显示储存库内容:

mt@mtmt:~$ svn list file:///svn/repository

.cache/

.project

.projectOptions

.settings/

bbscnmo/

newcnmo/

显示目录内容,成功导入。

上面使用了file:///形式的URL来访问Subversion库,这表示在本地通过文件系统访问。但我们的Subversion库可能需要通过网络被其它用户访问,这就需要用到其它的协议,下表是Subversion支持的各种访问协议:

访问协议

协议 访问方法

file:/// 通过本地磁盘访问。

http:// Apache组合,通过WebDAV协议访问。

https:// 同上,但支持SSL协议加密连接。

svn:// 通过svnserve服务自定义的协议访问。

svn+ssh:// 同上,但通过SSH协议加密连接。

2.配置 subversion Apache组合通过WebDAV方式访问Subversion

# apt-get install apache2 libapache2-svn

配置文件位于/etc/apache2/mods-enabled/目录下,配置文件共有两个,分别是dav_svn.confdav_svn.loaddav_svn.load文件负责装载必要的模块,内容如下:

# Load mod_dav_svn when apache starts

LoadModule dav_svn_module /usr/lib/apache2/modules/mod_dav_svn.so

LoadModule authz_svn_module /usr/lib/apache2/modules/mod_authz_svn.so

在装载mod_dav_svn.so前,必须先装载mod_dav.so模块。它由dav.load文件控制,内容如下:

LoadModule dav_module /usr/lib/apache2/modules/mod_dav.so

dav_svn.confmod_dav_svn.so模块的配置文件,内容如下:

# dav_svn.conf - Example Subversion/Apache configuration

#

# For details and further options see the Apache user manual and

# the Subversion book.

# …

# URL controls how the repository appears to the outside world.

# In this example clients access the repository as http://hostname/svn/

#设置访问路径

# Uncomment this to enable the repository,

DAV svn #启用by siko

# Set this to the path to your repository

SVNPath /data/subversion #设置储存库路径,仅支持单个储存库,该路径要可被Apache进程访问。

#SVNParentPath /data/subversion #如果subversion下有多个储存库,则用SVNParentPath

# The following allows for basic http authentication. Basic authentication

# should not be considered secure for any particularly rigorous definition of

# secure.

# to create a passwd file #按下面的步骤创建Apache用户验证文件

# # rm -f /etc/apache2/dav_svn.passwd

# # htpasswd2 -c /etc/apache2/dav_svn.passwd dwhedon

# New password:

# Re-type new password:

# Adding password for user dwhedon

# #

# Uncomment the following 3 lines to enable Basic Authentication

AuthType Basic #启用Apache基础验证

AuthName Subversion Repository #设置验证框标题

AuthUserFile /etc/apache2/dav_svn.passwd #指定验证用户文件名

# Uncomment the following line to enable Authz Authentication

AuthzSVNAccessFile /etc/apache2/dav_svn.authz #启用目录级别授权,dav_svn.authz是授权配置文档

# The following three lines allow anonymous read, but make

# committers authenticate themselves.

#

#允许匿名访问,不允许Commit,不能与AuthzSVNAccessFile同时使用

Require valid-user

#

修改/data/subversion目录访问权限使它可被Apache进程访问,我的Apache是用www-data启动的,所以设置方法如下:

# chown -R www-data.www-data /data/subversion

Apache的用户验证功能可以区别匿名用户和验证用户,从而赋予匿名用户读权限和验证用户读/写的权限。这些权限只能在全局范围内设置,不能设置具体 的某个目录是否能被某个用户操作。要实现目录级别的授权,就要使用mod_authz_svn.so模块提供的 AuthzSVNAccessFile指令。它会指定一个授权文档,该授权文档设置具体的目录权限。根据上面的配置,授权文档名叫 dav_svn.authz,它的内容如下:

[groups] #定义组

admin=jims,ringkee

tests=tester1,tester2

[erp:/] #定义erp储存库根目录的访问权限

@admin=rw #admin组有读写权限

tests=r #test用户只有读权限

[oa:/test] #定义oa储存库下test目录的访问权限

*= #禁止所有用户访问,星号代表所有用户,权限为空代表没有任何权限

ringkee=rw #打开ringkee用户的读写权限

在该文件中使用的用户需在apache2的用户文件/etc/apache2/dav_svn.passwd中预先设置好。

3.安装trac #sudo apt-get install trac 配置TRAC

#cd /trac/

#trac-admin repository initenv

在运行trac-admin时有一步设置需要注意,就是”Path to repository”,要指向上面的/svn/repository

chown -R www-data.www-data /trac/repository

CGI方式运行TRAC,有一些设置要做

建立密码文件:

htpasswd -c /somewhere/trac.htpasswd username

编辑apacheapache2.conf

#edit by siko@ 2006.11.24

ScriptAlias /trac /usr/share/trac/cgi-bin/trac.cgi

SetEnv TRAC_ENV “/trac/repository”

Alias /tracdoc “/usr/share/trac/htdocs/”

Options -Indexes -MultiViews

AllowOverride None

Order allow,deny

Allow from all

AuthType Basic

AuthName “Trac”

AuthUserFile /home/mt/trac.htpasswd

Require valid-user

重启apache使其生效

4. svneclipse插件 安装配置:

1.更新安装http://subclipse.tigris.org/updatesubclipse插件

2.安装完成后eclipse会自动重启后,在svn的透视图中可以看到svn的相关菜单

3.将新的 SVN 资源库添加至“SVN 资源库。urlhttp://your_ip/svn

4.引用项目成功后,便可以用前面的用户名和密码来更新和提交工程内文件了。

5.subclipse的较新版本都是中文的,详细操作略。svn有很多的客户端,在此只通过命令行来操作,结合eclipse的插件来控制版本并不涉及任何客户端程序。

posted on 2007-09-03 15:40 哼哼 阅读(318) 评论(0)  编辑  收藏 所属分类: JAVA-Common

只有注册用户登录后才能发表评论。


网站导航: