zoukankan      html  css  js  c++  java
  • centos6.0 配置SVN

    基本步骤: 1、安装必需的subversion 2、创建版本库 3、配置用户和权限 4、钩子和svn常用命令说明

    一、安装subversion 在这里我们使用yum来安装subversion,使用以下命令即可完成。

    [root@localhost ~]# yum -y install subversion 
    

    二、创建版本库

    [root@localhost ~]# mkdir -p /home/svn/project01
    [root@localhost ~]# svnadmin create /home/svn/project01
    

    三、版本库管理配置 进行刚才创建的版本库目录下的conf目录,可以看到有三个文件。

    [root@localhost ~]# cd /home/svn/project01/conf
    [root@localhost conf]# ls
    authz  passwd  svnserve.conf
    

    svnserve.conf 这个是版本库的配置文件 passwd 这个是记录用户帐号密码的文件 authz 这个则是记录组、权限和身份验证的文件 1、配置svnserve.conf文件 这里需要设置以下几处 anon-access = none 指定匿名权限,默认为可读,现设置匿名无权限 auth-access = write 用户有写权限 password-db = passwd 账号密码文件的路径,psswd文件也可复制一份,命名为 passwd.conf 这样可以知道是配置文件,也可以放到其它目录下 authz-db = authz 同上 注意去掉#注释以后配置一定要顶格写,下同。

    [root@localhost conf]# vi svnserve.conf
    anon-access = none
    auth-access = write
    password-db = passwd
    authz-db = authz

    2、配置passwd 该文件中记录svn用户名密码,以 (帐号 = 密码)或 (帐号 : 密码)的形式进行储存。 多用户之前用换行区分。这里配置了一个用户名为test1密码为123456的svn 账户。

    [root@localhost conf]# vi passwd
    ### This file is an example password file for svnserve.
    ### Its format is similar to that of svnserve.conf. As shown in the
    ### example below it contains one section labelled [users].
    ### The name and password for each user follow, one account per line.
    
    [users]
    # harry = harryssecret
    # sally = sallyssecret
    test1 = 123456

    3、authz文件的配置 [groups]表用于用户组的配置例如 “developers = test1,test2”这样就将这2个用户方在了developers组织之中。 建立组是为了方便给一组相同权限的用户分配权限。 [/] 指定是svn的根版本库 版本库目录格式: [<版本库>:/项目/目录] @<用户组名> = <权限> <用户名> = <权限>

    [root@localhost conf]# vi authz
    
    [groups]
    # harry_and_sally = harry,sally
    # developers = test1, test2
    
    # [/foo/bar]
    # harry = rw
    # * =
    
    # [repository:/baz/fuz]
    # @harry_and_sally = rw
    # * = r
    [/]
    test1 = rw
    * =

    这样svn版本库就算配置完成了。

    运行 svn, (停止SVN服务器命令为:killall svnserve )

    [root@localhost ~]# svnserve -d -r /home/svn/

    我们继续说下其他常用的一些配置 1、开机自动运行 在/etc/rc.d/rc.local 添加 “/usr/bin/svnserve -d -r svn版本库目录” 即可

    [root@localhost ~]# vi /etc/rc.d/rc.local
    
    #
    # This script will be executed *after* all the other init scripts.
    # You can put your own initialization stuff in here if you don't
    # want to do the full Sys V style init stuff.
    
    touch /var/lock/subsys/local
    /usr/bin/svnserve -d -r /home/svn/

    2、钩子自动更新 说明,在开发时经常需要提交代码,如果使用钩子自动更新的话,只要有人提交后就能自动更新到服务器上,非常方便哦。 首先必须对代码目录checkout

    [root@localhost ~]# cd /var/www
    [root@localhost www]# svn checkout svn://192.168.1.100/project01
    Authentication realm:  21d46c22-96a8-465b-9d0b-58a1e04abdfd
    Password for 'root':
    Authentication realm:  21d46c22-96a8-465b-9d0b-58a1e04abdfd
    Username: test1
    Password for 'test1':
    Checked out revision 0.

    这样在 /var/www/ 中会生成一个目录 project01,我们可以把这个目录设置成站点来访问。

    进入版本库hooks目录 将post-commit.tmpl 模板复制一份 取名post-commit 在末尾加上 svn up /home/svn/project01/ –username test1 –password 123456 并赋予执行权限。

    [root@localhost ~]# cd /home/svn/project01/hooks/
    [root@localhost hooks]# ls
    post-commit.tmpl  post-revprop-change.tmpl  pre-commit.tmpl  pre-revprop-change.tmpl  start-commit.tmpl
    post-lock.tmpl    post-unlock.tmpl          pre-lock.tmpl    pre-unlock.tmpl
    [root@localhost hooks]# cp post-commit.tmpl  post-commit
    [root@localhost hooks]# vim post-commit
    
    REPOS="$1"
    REV="$2"
    
    svn up /home/svn/project01/ --username test1 --password 123456
    
    [root@localhost hooks]# chmod +x post-commit

    这样当用户提交文件的第时候,svn将会自动执行更新,使代码同步。

  • 相关阅读:
    QT之sqlite连接
    QT之QCustomPlot(二)
    QT之QCustomPlot(一)
    Qt第三方库QCustomPlot——QCustomPlot解读
    C++ 头文件系列(sstream)
    C++ 头文件系列(streambuf)
    C++ 头文件系列(iostream)
    C++ 头文件系列(ostream)
    C++ 头文件系列(istream)
    C++ 头文件系列(ios)
  • 原文地址:https://www.cnblogs.com/zwl715/p/3651559.html
Copyright © 2011-2022 走看看