wsxxz 发表于 2015-8-2 10:30:18

在linux下搭建svn服务器,不带apache

折腾了一天,哎惭愧,对linux不熟啊。废话少说linux版本 Redhat4不用apache,直接用subversion
需要软件
subversion-1.4.5.tar.gz和subversion-deps-1.4.5.tar.gz安装包下载地址:
http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=7495&expandFolder=7495&folderID=260
安装和配置 subversion
#tar –zvxf subversion-1.4.5.tar.gz
#tar –zvxf subversion-deps-1.4.5.tar.gz /*这两个自动解压成一个包 subversion-1.4.5
#cd subversion-1.4.5
#rm –rf apr
#rm -rf apr-util
注意:SVN 依赖的APR版本要正确。如果Apache为2.0.x,对应的APR版本应为0.9.x;Apache为2.2.x,对应的APR版本应为1.2.x。 由于subversion-deps包里的APR是0.9.x的,因此编译svn时要删除从deps里解压出来的apr, apr-util,改而使用apache 2.2里提供的。(这里指定为开始安装的apr目录),这一点知识非常重要,自己之前多次安装都没成功,现在才明白是在这一点被卡住了,但最终还是被我解 决了, 学习,和不断实践 会使你不断成长!
#./configure
--prefix=/usr/local/svn
--with-apxs=/usr/local/apache/bin/apxs
--with-apr=/usr/local/apr/bin/apr-1-config
--with-apr-util=/usr/local/apr/bin/apu-1-config
--with-ssl
--with-zlib
--enable-maintainer-mode
#make
#make install
确定一下svn有没有安装成功
#/usr/local/svn/bin/svnserve - -version
会看到相关版本信息!
开始建立版本库
#/usr/local/svn/bin/svnadmin create /svn/project/projectname /*创建仓库"www"(需要事先建立好目录/svn/project)
#ls /svn/project/projectname /*查看有没有创建好,如果多了一些文件则说明版本库已经创建好
修改权限配置等
找到projectname/conf,下面应该有三个文件
authzpasswdsvnserve.conf
如果缺少文件手工加上去
缺省authz的内容:
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###- a single user,
###- a group of users defined in a special section,
###- an alias defined in a special section,
###- all authenticated users, using the '$authenticated' token,
###- only anonymous users, using the '$anonymous' token,
###- anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
#
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
#
# harry = rw
# &joe = r
# * =
#
# @harry_and_sally = rw
# * = r
Admin=use1,user2
Develop=use1,user2

@Admin=rw
@Develop=rw
---------------------结束
注意:要把#前的“#”去掉
缺省passwd的内容

user1:user1passwd
user2:user2passwd
---------------------结束
svnserve.conf的内容
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.(If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.tigris.org/ for more information.

### These options control access to the repository for unauthenticated
### and authenticated users.Valid values are "write", "read",
### and "none".The sample settings below are the defaults.
#anon-access = read
auth-access = write
### This file controls the configuration of the svnserve daemon, if you
### use it to allow access to this repository.(If you only allow
### access through http: and/or file: URLs, then this file is
### irrelevant.)
### Visit http://subversion.tigris.org/ for more information.

### These options control access to the repository for unauthenticated
### and authenticated users.Valid values are "write", "read",
### and "none".The sample settings below are the defaults.
#anon-access = read
auth-access = write
### The password-db option controls the location of the password
### database file.Unless you specify a path starting with a /,
### the file's location is relative to the conf directory.
### The format of the password database is similar to this file.
### It contains one section labelled . The name and
### password for each user follow, one account per line. The
### format is
###    USERNAME = PASSWORD
### Please note that both the user name and password are case
### sensitive. There is no default for the password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control.Unless you specify a path
### starting with a /, the file's location is relative to the the
### directory containing this file.If you don't specify an
### authz-db, no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
### This option specifies the authentication realm of the repository.
### If two repositories have the same authentication realm, they should
### have the same password database, and vice versa.The default realm
### is repository's uuid.
# realm = My First Repository
---------------------结束
去掉auth-access = write,password-db = passwd,authz-db = authz前的“#”,且前面不能有任何空格
启动svn服务
#/usr/local/svn/bin/svnserve -d -r /opt/svn/project

查看是否成功启动
ps –ef|grep svnserve
显示诸如下面则表示成功
  svn    6941   1 0 15:07 ?    00:00:00 svnserve -d --listen-port 9999 -r /opt/project
  
  将svn服务设置成开机自启动:
  vi /etc/rc.d/rc.local

  在最后面加上
  svnserve -d
  即可

  svn: Expected version '3' of repository; found version '5' / svn: Expected format '3' of repository; found format '5'
把你创建的项目的svn库目录下的/format(我指定的目录是/opt/svn/project/projectname/)文件中的5改成3就可以了.
在修改之前,由于format是只读方式的,你可能需要先chmod   666   format 一下

  今天遇到一个比较怪的问题:将服务器shutdown(reboot没问题)之后,执行任何操作都报No such revision 10,用svnadmin verify 一查 发现版本库丢失了,服务器上版本号只有0,没辙将repository删除了用svnadmin create命令重新建立,一切正常,当用客户端连接时又报:can't read file '****/db/revs/0': Is a directory

  我就郁闷了,一直都是这么建的 ,这回就不行了呢,反复尝试,始终不行,最后将subversion重新执行一遍configure,make,make install,再重新建立,刚开始好使,shutdown之后又不行了,最后发现在./configure 时指定 -prefix=***(一个路径,如/usr/local/svn)这样之后,就好了,无论怎样shutdown都没问题。

  对linux不熟悉,猜想可能是没有指定prefix时,默认安装在/usr/local目录下,同时有些数据文件会存放在类似临时目录下,当shutdown后就没了.
页: [1]
查看完整版本: 在linux下搭建svn服务器,不带apache