CentOS7 下搭建svn服务器

1、yum安装subversion
    1. 安装apache

subversion yum install subversion


    2. 查看安装版本,检查安装是否成功bash

svnserve --version


    3. 查看安装位置  服务器

rpm -ql subversion

2、建立版本库
        1. 建立用于存放版本库的目录less

mkdir -p /www/sdb1/subversion

        2. 建立svn版本库tcp

svnadmin create /www/sdb1/subversion

        3. 建立完后,版本库目录下会生成一些文件,进入conf目录下ide

            conf目录中authz文件是权限控制文件;svn

            conf目录中passwd是账号密码文件;ui

            conf目录中svnserve.conf是SVN服务配置文件this

                

  4. 修改passwd文件,加入用户,格式就是“用户名=密码”,如:  admin = 123日志

  5. 修改authz文件,加入用户权限:

    [/] 

    admin = rw

   这就表示admin用户对版本库根目录有读写权限(即最高权限了),权限配置方式在authz文件注释中有详细说明

  6. svnserve.conf里面经常使用的配置有设置匿名用户(默承认读)、受权用户(默认读写)的读写权限,以及指定帐号文件(默认passwd)、权限文件(默认authz)的路径等

        

### 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.apache.org/ for more information.

[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete 
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
# 匿名用户权限(none:拒绝, write:读写, read:只读权限)
anon-access = none
# 鉴权用户访问
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 directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default 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
### The force-username-case option causes svnserve to case-normalize
### usernames before comparing them against the authorization rules in the
### authz-db file configured above.  Valid values are "upper" (to upper-
### case the usernames), "lower" (to lowercase the usernames), and
### "none" (to compare usernames as-is without case conversion, which
### is the default behavior).
# force-username-case = none

[sasl]
### This option specifies whether you want to use the Cyrus SASL
### library for authentication. Default is false.
### This section will be ignored if svnserve is not built with Cyrus
### SASL support; to check, run 'svnserve --version' and look for a line
### reading 'Cyrus SASL authentication is available.'
# use-sasl = true
### These options specify the desired strength of the security layer
### that you want SASL to provide. 0 means no encryption, 1 means
### integrity-checking only, values larger than 1 are correlated
### to the effective key length for encryption (e.g. 128 means 128-bit
### encryption). The values below are the defaults.
# min-encryption = 0
# max-encryption = 256

  7. 启动svn版本库 svnserve -d -r  /www/sdb1/subversion

   其中,-r 的做用是设置根目录路径,好比这样设置后在访问时输入svn://x.x.x.x/就会直接到个人svn目录下(固然在svn目录下是找不到版本库的)。换句说话,若是启动版本库时命令为svnserve -d -r  /www/sdb1/subversion,则访问svn://x.x.x.x/就能直接到版本库内。

3、开启和关闭服务

svnserve -d -r /www/sdb1/subversion #开启
killall svnserve #关闭
ps aux | grep svnserve #查看是否运行

4、常见问题
  1. 注意打开端口的访问权限。svn服务的默认端口为3690 

        CentOS7 以前版本iptables 防火墙:

CentOS7 以前版本iptables 防火墙
iptables -I INPUT -i eth0 -p tcp --dport 3690 -j ACCEPT #开放端口 
service iptables save #保存 iptables 规则(如不能保存请使用其余方法保存)

        CentOS7  版本 firewalld 防火墙:

CentOS7  版本 firewalld 防火墙:
添加(--permanent永久生效,没有此参数重启后失效)
firewall-cmd --zone=public --add-port=80/tcp --permanent    
从新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp

        2. 客户端svn上传后,原始文件在服务器的什么位置
        SVN服务器端不是简单将上传的文件一个一个存放起来的;SVN服务器端默认采用的FSFS格式是将每次commit的内容增量方式存放的,每一个增量包存成1个文件,这个增量包中包括了此次commit的所有数据。也就是说你不可能在服务器端存放该版本库的文件夹下找到你上传的某个文件。

        SVN服务器版本库有两种格式,

            一种为FSFS,

            一种为BDB

        把文件上传到SVN版本库后,上传的文件再也不以文件原来的格式存储,而是被svn以它自定义的格式压缩成版本库数据,存放在版本库中。

        若是是FSFS格式,这些数据存放在版本库的db目录中,里面的revs和revprops分别存放着每次提交的差别数据和日志等信息 。
        3. 怎把指定文件夹上传到SVN服务器
        通常来讲新建项目是在服务器端操做的,每一个项目做为一个独立的版本库进行管理。固然你能够能够把这个项目看成服务器上某个版本库下面的一个文件夹进行管理,可是会致使这个项目的版本号看起来是不连续的,由于SVN是用版本号标注整个版本库的状态。
        你若是肯定想把这个项目当成某个版本库的一个文件夹进行管理的话,那么就这么作:
        首先,用TSVN检出那个版本库到本地;而后,将这个项目复制到本地这个版本库的某个文件夹下面;
最后,用TSVN增长并提交这个文件夹。

        SVN在服务器端的存储方式和客户端是不同的,因此在服务器端是看不到源文件的。服务器端有两种存储方式FSFS和BDB,目前默认都是FSFS。

        要导入文件有两种作法:         一、用import指令,将客户端文件夹导入到服务器端         二、先checkout空库到客户端,而后将要导入的文件夹放入客户端checkout产生的空文件夹,而后执行add将这些文件夹归入SVN控制,最后执行commit上传到服务器

相关文章
相关标签/搜索