linux 架设subversion

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

2.新建一个用户:svnroot

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

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

//解压apache2安装包

# tar xvzf httpd-2.2.2.tar.gz

//进入解压后的目录

# cd httpd-2.2.2

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

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

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

# make

//安装

# make install

# cd /usr/local/apache2/bin

//启动apache服务

# ./apachectl start

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

4.

安装Subversion

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

# tar xvzf Subversion-1.3.1.tar.gz

//进入解压后的目录

# cd Subversion-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

//安装

# make install

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

# mkdir /home/svnroot/repository

//进入subversion的bin目录

# cd /usr/local/subversion/bin

//创建仓库"test"

# ./svnadmin create /home/svnroot/repository/test

# cd /home/svnroot/repository/test

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

# ls –l

# cd /usr/local/subversion/bin

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

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

# ./svn import /home/user/import file:///home/svnroot/repository/test –m "注释"

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

# chmod 700 /home/svnroot/repository

5.修改Apache配置文件

# cd /usr/local/apadche2/bin

//启动Apache

# ./apachect1 start

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

//在最下面添加

LoadModule dav_svn_module modules/mod_dav_svn.so

LoadModule authz_svn_module modules/mod_authz_svn.so

DAV svn

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

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

AuthType Basic //连接类型设置

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

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

Require valid-user //采用何种认证

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

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

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

6.重启apache

# ./usr/local/apache2/bin/apachectl restart

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

7.权限管理

1)增加用户

# htpasswd [-c] /home/svnroot/repository/authfile wooin

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

# htpasswd authfile 用户名(加入新的用户)

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 文件中配置,找到文件中的这两行:

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

Group daemon

2。

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

# start apache server for svn

/usr/sbin/apachectl start

export SVN_EDITOR=vi

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

启apache error

/etc/init.d/httpd restart

Syntax error on line 235 of /VDS/localpram/apache2/conf/httpd.conf:

Cannot load /VDS/localpram/apache2/modules/mod_dav_svn.so into server: /VDS/localpram/apache2/modules/mod_dav_svn.so: undefined symbol: dav_xml_get_cdata

原因:安装apache的时候没加--enable-dav --enable-so 重新编译安装可以了

The Apache Portable Runtime (APR) library cannot be found.

Please install APR on this system and supply the appropriate

--with-apr option to 'configure'

or

get it with SVN and put it in a subdirectory of this source:

svn co \

http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x \

apr

Run that right here in the top level of the Subversion tree,

then run autogen.sh again.

Whichever of the above you do, you probably need to do

something similar for apr-util, either providing both

--with-apr and --with-apr-util to 'configure', or

getting both from SVN with:

svn co \

http://svn.apache.org/repos/asf/apr/apr-util/branches/0.9.x \

apr-util

configure: error: no suitable apr found

解决方法:下载subversion-deps-1.4.3.tar.bz2解压在同一目录下


猜你喜欢

转载自jefry.iteye.com/blog/792087