zoukankan      html  css  js  c++  java
  • Linux搭建SVN服务器

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

     1.新建一个目录用于存储SVN所有文件

    [root@centos02 ~]# mkdir /svn
    

     2. 新建一个资源仓库

    [root@centos02 ~]# svnadmin create /svn/project
    
    [root@centos02 ~]# tree /svn
    /svn
    └── project
        ├── conf
        │   ├── authz
        │   ├── passwd
        │   └── svnserve.conf
        ├── db
        │   ├── current
        │   ├── format
        │   ├── fsfs.conf
        │   ├── fs-type
        │   ├── min-unpacked-rev
        │   ├── rep-cache.db
        │   ├── revprops
        │   │   └── 0
        │   │       └── 0
        │   ├── revs
        │   │   └── 0
        │   │       └── 0
        │   ├── transactions
        │   ├── txn-current
        │   ├── txn-current-lock
        │   ├── txn-protorevs
        │   ├── uuid
        │   └── write-lock
        ├── format
        ├── hooks
        │   ├── post-commit.tmpl
        │   ├── post-lock.tmpl
        │   ├── post-revprop-change.tmpl
        │   ├── post-unlock.tmpl
        │   ├── pre-commit.tmpl
        │   ├── pre-lock.tmpl
        │   ├── pre-revprop-change.tmpl
        │   ├── pre-unlock.tmpl
        │   └── start-commit.tmpl
        ├── locks
        │   ├── db.lock
        │   └── db-logs.lock
        └── README.txt
    
    11 directories, 28 files
    
    [root@centos02 project]# ls
    conf  db  format  hooks  locks  README.txt
    
    目录用途说明:
    
    l hooks目录:放置hook脚本文件的目录
    
    l locks目录:用来放置subversion的db锁文件和db_logs锁文件的目录,用来追踪存取文件库的客户端
    
    l format文件:是一个文本文件,里面只放了一个整数,表示当前文件库配置的版本号
    
    l conf目录:是这个仓库的配置文件(仓库的用户访问账号、权限等)
    
    3. 配置svn服务的配置文件svnserver.conf文件 
    
    [root@centos02 project]# vi /svn/project/conf/svnserve.conf 
    
    [general]
    anon-access = read
    auth-access = write
    password-db = /svn/project/conf/passwd
    authz-db = /svn/project/conf/authz
    realm = clnking
    
    [root@centos02 project]# vi /svn/project/conf/passwd
    
    [users]
    # harry = harryssecret
    # sally = sallyssecret
    chenlin = 123456
    test1 = 123
    test2 = 123
    

     注意:对用户配置文件的修改立即生效,不必重启svn服务。

    [root@centos02 project]# vim /svn/project/conf/authz 
    
    [aliases]
    # joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average
    
    [groups]
    # harry_and_sally = harry,sally
    # harry_sally_and_joe = harry,sally,&joe
    admin = chenlin
    user = test2,test1
    # [/foo/bar]
    # harry = rw
    # &joe = r
    # * =
    [/]
    @admin = rw
    
    格式说明:
    
    版本库目录格式:
    
    [<版本库>:/项目/目录]
    
    @<用户组名> = <权限>
    
    <用户名> = <权限>
    
    / 表示对根目录(即/svn/project目录)下的所有子目录范围设置权限;
    
    [/abc] 表示对资料库中abc项目设置权限;
    
    创建一个admin组,组成员包括chenlin
    
    创建一个user组,成员只有test2,test1;
    
    admin组对目录有读写权限;
    
    单个用户test2有读写权限;
    
    *=表示除了上面设置的权限用户组以外,其他所有用户都设置空权限,空权限表示禁止访问本目录,这很重要一定要加上。
    
    注意:对权限配置文件的修改立即生效,不必重启svn。
    

    启动svn服务  

    [root@centos02 project]# svnserve -d -r /svn/project/
    
    [root@centos02 project]# ps -ef |grep svn
    root      3809     1  0 05:29 ?        00:00:00 svnserve -d -r /svn/project/
    root      3811  3707  0 05:30 pts/1    00:00:00 grep svn
    
    [root@centos02 project]# netstat -lnutp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
    tcp        0      0 0.0.0.0:3690                0.0.0.0:*                   LISTEN      3809/svnserve       
    tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      1767/mysqld         
    tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      1571/nginx          
    tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1334/sshd           
    tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1424/master         
    tcp        0      0 :::22                       :::*                        LISTEN      1334/sshd           
    tcp        0      0 ::1:25                      :::*                        LISTEN      1424/master         
    udp        0      0 0.0.0.0:68                  0.0.0.0:*                               3521/dhclient  
    
    [root@localhost hooks]# ls
    post-commit       post-lock.tmpl            post-unlock.tmpl  pre-lock.tmpl            pre-unlock.tmpl
    post-revprop-change.tmpl  pre-commit.tmpl   pre-revprop-change.tmpl  start-commit.tmpl
    
    #!/bin/sh
    REPOS="$1"
    REV="$2"
    export LANG=zh_CN.UTF-8
    SVN_PATH=/usr/bin/svn
    WEB_USER=daemon
    LOG_PATH=/tmp/svn.log
    /usr/bin/svn update --username ecuser1 --password ecuser1 /opt/redmine-3.2.0-1/apache2/htdocs/test --no-auth-cache >> /tmp/svn.log
    #/usr/bin/svn update --username ecuser1 --password ecuser1 /opt/redmine-3.2.0-1/apache2/htdocs/test2 --no-auth-cache >> /tmp/svn.log
    /usr/bin/svn update --username ecuser1 --password ecuser1 /opt/redmine-3.2.0-1/apache2/htdocs/mobile --no-auth-cache >> /tmp/svn.log
    /usr/bin/svn update --username ecuser1 --password ecuser1 /opt/redmine-3.2.0-1/apache2/htdocs/framework --no-auth-cache >> /tmp/svn.log
    chown daemon.daemon -R /opt/redmine-3.2.0-1/apache2/htdocs/test
    
    svn checkout svn://192.168.1.17/ecshop/PHP/mbshunfeng2015273 test
    
  • 相关阅读:
    yourphp常用标签
    如何访问他人电脑上的共享文件夹
    Win7如何分享局域网并设置共享文件夹账户和密码
    CLR Via CSharp读书笔记(21):自动内存管理(垃圾回收)
    《Java编程思想》之I/O系统
    WebCore::Node Dump
    java中的IO整理(3)数据操作流合并流压缩流输入输出重定向 老秋的日志 网易博客
    WebKit 分析–for android Braincol 博客园
    JavaScript EE,第 2 部分: 用 Ajax 调用远程 JavaScript 函数
    java中System重定向输出流
  • 原文地址:https://www.cnblogs.com/bass6/p/5453319.html
Copyright © 2011-2022 走看看