参考下面文章试了一下,有一些需要注意的地方,记录下来:

1.使用版本如下:

httpd-2.2.21.tar.gz

subversion-1.7.1.tar.gz

2.安装apache时,参数如下

./configure-prefix=/usr/local/apache2-enable-dav-enable-so-enable-maintainer-mode-enable-rewrite

3.安装svn前需要做如下操作

subversion-1.7.1>./get-deps.sh

yuminstallopenssl

yuminstallopenssl-devel

4.如果遇到以下问题,可能是httpd.conf注释问题,注释使用#,不能使用//

[root@localhostbin]#./apachectlstart

Syntaxerroronline422of/usr/local/apache2/conf/httpd.conf:

SVNParentPathtakesoneargument,specifiesthelocationinthefilesystemwhosesubdirectoriesareassumedtobeSubversionrepositories.

5.如果使用selinux,需要用chcon赋权限

6.如果遇到以下错误,使用htpasswd重新生成密码,确保authfile中是密文

[SunNov2016:15:142011][error][client127.0.0.1]usertest:authenticationfailurefor"/svn/test":PasswordMismatch

7.如果遇到以下错误,需要新建authz.conf文件,以下是最简单的一种形式

[/]

*=rw

[SunNov2016:36:182011][error][client192.168.224.1](2)Nosuchfileordirectory:FailedtoloadtheAuthzSVNAccessFile:Can'topenfile'/home/svnadmin/repository/authz.conf':Nosuchfileordirectory

http://mhbjava.iteye.com/blog/26594

1.需要两个文件,httpd和subversion.httpd是web服务器,用来通过web访问subversion,httpd可以在apache官方网站上下载到

2.新建一个用户:svnroot

最好不要让root用户参与到svn的权限管理和日常的运行和维护工作中来,但是下面的一些安装和配置操作还是需要root用户来完成的,因为有些操作只有root才能做。权限问题很重要。曾经因为权限问题折腾了一天。

3.编译安装httpd(root用户操作):

//解压apache2安装包

#tarxvzfhttpd-2.2.2.tar.gz

//进入解压后的目录

#cdhttpd-2.2.2

//配置apache安装,前两个参数是必须要加的,你还可以根据您的需要添加其他的参数。

//后面的参数制定你要把apache安装哪里

#./configure--enable-dav--enable-so--prefix=/usr/local/apache2/

#make

//安装

#makeinstall

#cd/usr/local/apache2/bin

//启动apache服务

#./apachectlstart

//打开浏览器http://localhost/如果有测试页"Itworks!"出现则证明已经安装成功。

4.

安装Subversion

//解压SubVersion安装包(root用户进行下面的操作)

#tarxvzfSubversion-1.3.1.tar.gz

//进入解压后的目录

#cdSubversion-1.3.1

//配置subversion安装

#./configure--with-apxs=/usr/local/apache2/bin/apxs--prefix=/usr/local/subversion

--with-apr=/usr/local/apache2--with-apr-util=/usr/local/apache2--with-ssl--with-zlib

--enable-maintainer-mode

#make

//安装

#makeinstall

//创建库文件所在的目录(svnroot用户进行下面的操作)

#mkdir/home/svnroot/repository

//进入subversion的bin目录

#cd/usr/local/subversion/bin

//创建仓库"test"

#./svnadmincreate/home/svnroot/repository/test

#cd/home/svnroot/repository/test

//看看是不是多了些文件,如果是则说明Subversion安装成功了

#ls–l

#cd/usr/local/subversion/bin

//这条语句将把路径/home/user/import下找到的文件导入到你创建的Subversion仓库中去,

//提交后的修订版为1。

#./svnimport/home/user/importfile:///home/svnroot/repository/test–m"注释"

//不让其他人有该目录的权限

#chmod700/home/svnroot/repository

5.修改Apache配置文件

#cd/usr/local/apadche2/bin

//启动Apache

#./apachect1start

#vi/usr/local/apache2/conf/httpd.conf

//在最下面添加

LoadModuledav_svn_modulemodules/mod_dav_svn.so

LoadModuleauthz_svn_modulemodules/mod_authz_svn.so

<Location/svn>

DAVsvn

SVNParentPath/home/svnroot/repository///svn父目录

AuthzSVNAccessFile/home/svnroot/repository/authz.conf//权限配置文件

AuthTypeBasic//连接类型设置

AuthName"Subversion.zoneyump"//连接框提示

AuthUserFile/home/svnroot/repository/authfile//用户配置文件

Requirevalid-user//采用何种认证

</Location>

//其中authfile是通过"htpasswd[–c]/home/svnroot/repository/authfileusernamepassword"来创建的

//"Requirevalid-user"告诉apache在authfile中所有的用户都可以访问。如果没有它,

//则只能第一个用户可以访问新建库

6.重启apache

#./usr/local/apache2/bin/apachectlrestart

//打开浏览器访问http://localhost/svn/test/,如果有东西显示就说明成功。

7.权限管理

1)增加用户

#htpasswd[-c]/home/svnroot/repository/authfilewooin

//第一次设置用户时使用-c表示新建一个用户文件。回车后输入用户密码,完成对用户的增加

#htpasswdauthfile用户名(加入新的用户)

2)权限分配

#vi/home/svnroot/repository/authz.conf

[test:/]//这表示,仓库test的根目录下的访问权限

wooin=rw//test仓库wooin用户具有读和写权限

bao=r//test仓库bao用户具有读权限

[test2:/]//test2仓库根目录下的访问权限

wooin=r//wooin用户在test2仓库根目录下只有读权限

bao=//bao用户在test2仓库根目录下无任何权限

[/]//这个表示在所有仓库的根目录下

*=r//这个表示对所有的用户都具有读权限

#[groups]//这个表示群组设置

#svn1-developers=wooin,bao//这个表示某群组里的成员

#svn2-developers=wooin

#[svn1:/]

#@svn1-developers=rw//如果在前面加上@符号,则表示这是个群组权限设置

将这个设置完成后。重启Apache,就可以通过

http://localhost/svn/test

这个URL来访问仓库了,当然,受权限的限制,必须是合法用户才能访问且具有相应的权限

备注:

1。apache进程的权限:因为所有跟仓库传输的操作都是通过apache进程进行的,所以即使你给svn用户设置了很大的权限,但是apache进程没有访问仓库或者相关文件的权限也没有用,apache进程的权限设置在/usr/local/apache2/conf/httpd.conf文件中配置,找到文件中的这两行:

Userdaemon#将daemon改为svnroot,让apache进程以svnroot的身份运行

Groupdaemon

2。

在/etc/profile的结尾设置一些svn启动时要做的工作

#startapacheserverforsvn

/usr/sbin/apachectlstart

exportSVN_EDITOR=vi

3。/home/respository/svnroot下的文件操作权限有给svnroot.