linux下搭建svn全指南

linux svn安装部署

使用yum search subversion获取需要安装的包

[root@localhost ~]# yum search subversion

 

subversion.i386 : Modern Version Control System designed to replace CVS

subversion-devel.i386 : Development package for Subversion developers.

subversion-javahl.i386 : JNI bindings to the Subversion libraries

subversion-perl.i386 : Perl bindings to the Subversion libraries

subversion-ruby.i386 : Ruby bindings to the Subversion libraries

 

依次安装以上的的subversion文件

yum install subversion subversion-devel subversion-javahl subversion-perl subversion-ruby

===========================================

安装完毕后,建立linux SVN创库文件

mkdir /svn

cd /svn

mkdir repos

svnadmin create repos

//付权限

chmod 755 /svn

======================================

编辑/svn/repos/conf/svnserve.conf

 

vi /svn/repos/conf/svnserve.conf

解开注释,记住这里的文件命令都必须抵头写,不能留空格,否则报错

anon-access = read

auth-access = write

password-db = passwd

authz-db = authz

============================================

vi /svn/repos/conf/passwd

user=pwd

如:tearsky=123456

用户:就是tearsky,密码就是123456

===============================

vi /svn/repos/conf/authz

 

追加下记文字

[groups]

# harry_and_sally = harry,sally

# harry_sally_and_joe = harry,sally,&joe

develop = zhuzhengling,zhangqiyu,zhangmengying,baoxiufen

 

 

# [/foo/bar]

# harry = rw

# &joe = r

# * =

 

# [repository:/baz/fuz]

# @harry_and_sally = rw

# * = r

[repos:/]

lisb=rw

@develop=rw

[/]

*=r

------------*=r 设置组,只有读取权限,可设置一个readTest=r,限制其他人访问svn,如果是rw表示可读可写

 

 

=======================================================

执行svnserve -d -r /svn/repos/ 启动服务

 

-d 启动,-r路径

 

 

==============================linux svn apache安装========================

svn安装同上

apache 安装

通过yum search httpd,找出需要安装的文件,

[root@TTenv conf.d]# yum search httpd

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.btte.net

 * extras: mirrors.btte.net

 * updates: mirrors.btte.net

=========================================================================== Matched: httpd ============================================================================

mod_ssl.x86_64 : SSL/TLS module for the Apache HTTP server

system-config-httpd.noarch : Apache configuration tool

centos-ds.x86_64 : CentOS Directory, Administration, and Console Suite

httpd.x86_64 : Apache HTTP Server

httpd-devel.i386 : Development tools for the Apache HTTP server.

httpd-devel.x86_64 : Development tools for the Apache HTTP server.

httpd-manual.x86_64 : Documentation for the Apache HTTP server.

mod_dav_svn.x86_64 : Apache server module for Subversion server.

 

 

 

yum install -y httpd....进行安装

[root@TTenv conf.d]# yum install -y mod_ssl system-config-httpd centos-ds httpd httpd-devel httpd-devel httpd-manual mod_dav_svn

 

安装完毕后,

新建用户

输入:htpasswd -c /svn/passwd.conf lisb  回车

输入两次密码

-c 只有文件不存在的时候才用,有这个文件了,就不用-c了,/svn新建的文件在/svn下面的passwd.conf,可以任意指定,lisb 里账号名字 

 

如:创建新用户 htpasswd /svn/passwd.conf zhuzhengling

 

 

再复制/svn/repos/conf里面的authz文件到/svn下面,修改名字为authz.conf,也可以任意指定目录

cp /svn/repos/conf/authz /svn/authz.conf

 

authz.conf内容如下

[root@TTenv svn]# vi authz.conf 

 

[groups]

dev_user=chenbs,lisb,zhuyt,tanggy,yangxz

#dev_user=lisb,zhuzhengling,zhangqiyu,baoxiufen,zhangmengying

[/]

@dev_user=rw

 

 

模块加载

//一般来说下面两个文件会自动弄好,不用我们管

 

打开/etc/httpd/conf.d/subversion.conf,这个文件中的如下两行取消注释。

LoadModule dav_svn_module     modules/mod_dav_svn.so

LoadModule authz_svn_module   modules/mod_authz_svn.so

 

 

 

相应的so文件已经自动copy到了APACHE/modules。这些工作就不用自己动手了。

 

版本库控制

[root@TTenv svn]# vi /etc/httpd/conf.d/subversion.conf 

添加如下内容

<Location /svn/>#svn在访问的时候用到,http://ip/svn   3.DAV svn           #不用修改   

DAV svn

SVNParentPath /svn#资料库的绝对地址

SVNListParentPath on

AuthType Basic

AuthName "Subversion repository"

AuthzSVNAccessFile /svn/authz.conf#权限文件

AuthUserFile /svn/passwd.conf#账号文件

Require valid-user

</Location>

=========================

 

在这里就设置完成了

重启httpd

service httpd restart

 

 

==============================

注意事项

 

注意:

(1)单个版本库就是SVNPath /svn/svnroot/icec跟./svnadmin create /svn/svnroot/icec目录要一样,要不忙死你……【这个是对单个版本库】,多个版本库知道svn的主目录,

我这就是 SVNParentPath /svn/svnroot

(2)AuthzSVNAccessFile是权限控制文件,单个版本库不需要,多个版本库要设置不同版本库的权限

(3)目录svnroot目录的权限设置成755

 

 

四、验证安装

打开浏览器,输入地址为http://服务器ip/

出现登陆窗口,输入用户名跟密码,

 

如果可以正常打开如上页面则说明安装配置正常,可以正常使用了,在页面上可以看到由于目前资料库中没有内容,因此看到的内容为空。

 

五、导入数据到资料库

Cd /usr/local/subversion/bin

./svn import /要导入的目录 file:///svn/svnroot -m “说明文字”

重新打开浏览器,输入地址http://服务器ip/svn,输入用户名密码。

 

安装配置就完成了。

 

 

 

以下摘抄于http://www.dasairen.com/Centos/19023011232.html

六、可能遇到的问题

 

整个过程不会一帆风顺的,这里介绍一些可能遇到的问题。

 

1、【这个问题是我创建单个版本库时遇到的】安装好了后,浏览器打开http://服务器ip/svn,登陆出现不了页面,出现:

<D:error>

 

<C:error/> <m:human-readable errcode="2"> Could not open the requested SVN filesystem </m:human-readable> </D:error>

解决:这是httpd.conf里的<Locate svn>中的SVNPath指向错误没指到创建的资料库

 

2、输入账号密码提示不能认证,查看APACHE的/etc/httpd/logs/error_log,有如下提示:

 

[Tue Oct 05 18:07:09 2010] [error] [client 125.223.118.90] (13)Permission denied: Could not open password file: /svn/svnroot/passwd

[Tue Oct 05 18:07:09 2010] [error] [client 125.223.118.90] access to /svn failed, reason: verification of user id 'test' not configured

 

从日志看,因为检查过配置文件没有拼错,所以可以肯定是权限问题。从ls命令的结果可以看出,由于passwd的权限是没有问题的。

后来看了一位朋友的帖子【Linux环境下搭建APACHE+subversion+svnmanager】的启发,可能是SELinux引发的问题,

于是执行命令:

chcon -R -h -t httpd_sys_content_t /svn/svnroot

后来还是不行。执行以下命令后搞定

chcon -R -h -t httpd_sys_content_t /svn

 

总结教训:还是linux不熟悉的原因造成的,我是linux的新手。看来得恶补linux的基本知识。

 

3、组(group)设置

 

在TortoiseSVN中做Commit操作时可能遇到如下错误:

 

can't open file '/svn/svnroot/telnet/db/txn-current-lock': Permission denied

 

可以将telnet的所属组设置为APACHE

 

chgrp -R APACHE  /svn/svnroot/telnet

 

4、文件夹创建删除属性

 

在TortoiseSVN中做Commit操作时可能遇到如下错误:

 

can't open '/svn/svnroot/telnet/db/tempfile.tmp': Permission denied

 

can't make directory '/svn/svnroot/telnet/dav/activities.d': Permission denied

 

设置telnet 群组的访问方式为“创建和删除文件”

 

 

5、The URI does not contain the name of a repository. [403, #190001

 

 

这个原因是因为httpd.conf文件里SVNParentPath

 

加上这行代码后必须在你的访问URL中访问你的SVN下的具体的库

 

如果开启父目录显示就不会有这个问题了,即加上SVNListParentPath on

还有意Location /svn/的svn后面有一条斜线。

 

 

 

 

 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#停止 HTTPD服务

[root@zhangxx etc]# service httpd stop

停止 httpd:[  确定  ]

#启动httpd服务

[root@zhangxx etc]# service httpd start

启动 httpd:[  确定  ]

#重起HTTD服务

[root@zhangxx etc]# service httpd restart

停止 httpd:[  确定  ]

启动 httpd:[  确定  ]

#让httpd 在机器启动的时候在运行级别上停止

[root@zhangxx etc]# chkconfig --level 345 httpd off

[root@zhangxx etc]# chkconfig --list |grep httpd

httpd           0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭

#让httpd 在机器启动的时候在运行级别上启动

[root@zhangxx etc]# chkconfig --level 345 httpd on

[root@zhangxx etc]# chkconfig --list |grep httpd

httpd           0:关闭  1:关闭  2:关闭  3:启用  4:启用  5:启用  6:关闭

 

 

查看svnserve进程

ps -ef|grep svnserve

杀进程

killall svnserve

启动:

svnserve -d -r /svn/repos/

svnserve -d -r /svn/nj_repository/

 

查看httpd 进程

ps -ef|grep httpd

启动 httpd

 

service httpd stop

service httpd start

 

创建版本库

svnadmin create /svn/njsvnresource 

 

svn import /home/oss file:///svn/nj_repository/jiashitong/oss -m "导入文件"

 

 

svnserve -d -r /svn/nj_repository/jiashitong --config-file=/svn/nj_repository/jiashitong/svnserve.conf

 

svnserve -d -r /data/svn --config-file=/data/svn/svnserve.conf

 

tail -200f /etc/httpd/logs/error_log

 

http://lesterlee.cn/?p=172

 

新增用户

编辑

/svn/authz.conf

htpasswd /svn/passwd.conf 用户名

killall svnserve

service httpd stop

svnserve -d -r /svn/repos/

service httpd start

猜你喜欢

转载自sonofgod.iteye.com/blog/2039780
今日推荐