zoukankan      html  css  js  c++  java
  • Ubuntu 12.04搭建svn服务器【转】

    这是一个比较老旧的话题,毕竟大家现在都使用Git(http://git-scm.com/),Git在分支、代码存储、冲突、速度方面的机制都更优秀。

    那我们难道还有使用svn的场景?当然,比如对Git很陌生却要快速推进项目,再比如转换成本很高的场景。。。。总之技术上永远没有孰优孰劣,只是看使用的场景而已

    进入正题,ssh服务器,切换到root用户,首先安装subversion:

    apt-get install subversion

    然后创建svn目录:

    mkdir /home/svn

    然后创建项目目录,xxxx为我们假定的目录名:

    mkdir /home/svn/xxxx
    cd /home/
    svn
    chmod
     -R 777 xxxx

    然后就是初始化svn仓库:

    svnadmin create /home/svn/xxxx

    现在在项目目录里面会生成一堆文件和文件夹,至此项目基本搭建完成,下面进行权限部分

    我们设定常用的场景是这样的,没有认证的用户只能读,认证之后的用户可以读写,认证是通过密码进行,let’s go:

    cd /home/svn/xxxx/conf
    vim svnserver.conf

    然后注释以下3行,注意,开头不能有空格存在

    anon-access = read //没有验证的用户只能读
    auth-access = write //验证的用户能够读写
    password-db = passwd //密码数据是当前目录下的passwd文件

    然后我们就开始添加密码了

    cd /home/svn/xxxx/conf
    vim 
    passwd

    然后以如下格式添加用户名和密码:

    username = passwd

    还差最后一步,就是启动svn服务器:

    svnserve -d -r /home/svn

    -d 表示svnserver以“守护”进程模式运行
    -r 指定文件系统的根位置,这样客户端不用输入全路径,就可以访问版本库
    如:svn://youip/xxxx,eg: svn://192.168.1.7/xxxx

    然后就可以开始使用啦

     

     

     

    http://dashu.me/ubuntu-12-04%E6%90%AD%E5%BB%BAsvn%E6%9C%8D%E5%8A%A1%E5%99%A8/

     

     

    ubuntu@10-4-8-71:/home/git$ svnadmin create svnpro
    ubuntu@10-4-8-71:/home/git$ cd svnpro/conf
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ vim svnerver.conf
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ ll
    total 20
    drwxrwxr-x 2 ubuntu ubuntu 4096 Mar 18 16:20 ./
    drwxrwxrwx 6 root   root   4096 Mar 18 16:20 ../
    -rw-rw-r-- 1 ubuntu ubuntu 1080 Mar 18 16:20 authz
    -rw-rw-r-- 1 ubuntu ubuntu  309 Mar 18 16:20 passwd
    -rw-rw-r-- 1 ubuntu ubuntu 3090 Mar 18 16:20 svnserve.conf
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ vim svnerve.conf
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ vim svnserve.conf
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ vim passwd
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ svnserve -d -r /home/git
    svnserve: E000098: Can't bind server socket: Address already in use
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ ps -A |grep svn
    19312 ?        00:00:00 svnserve
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ kill 19312
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ svnserve -d -r /home/git
    ubuntu@10-4-8-71:/home/git/svnpro/conf$ cd /tmp
    ubuntu@10-4-8-71:/tmp$ ls
    ubuntu@10-4-8-71:/tmp$ mkdir shit
    ubuntu@10-4-8-71:/tmp$ cd shit
    ubuntu@10-4-8-71:/tmp/shit$ svn checkout svn://10.4.8.71/svnpro
    Checked out revision 0.
    ubuntu@10-4-8-71:/tmp/shit$ netstat
    drwxrwxr-x 4 ubuntu ubuntu 4096 Mar 18 16:25 .svn/
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn diff
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn diff
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ ll
    total 12
    drwxrwxr-x 3 ubuntu ubuntu 4096 Mar 18 16:25 ./
    drwxrwxr-x 3 ubuntu ubuntu 4096 Mar 18 16:25 ../
    drwxrwxr-x 4 ubuntu ubuntu 4096 Mar 18 16:25 .svn/
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn update
    Updating '.':
    At revision 0.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo nano asdf
    [sudo] password for ubuntu:
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn update
    Updating '.':
    At revision 0.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn commit -m 'asdf'
    svn: E205005: The log message is a pathname (was -F intended?); use '--force-log                                                                                                 ' to override
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn commit -m "asdf"
    svn: E205005: The log message is a pathname (was -F intended?); use '--force-log                                                                                                 ' to override
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn commit -m "asdf"
    svn: E205005: The log message is a pathname (was -F intended?); use '--force-log                                                                                                 ' to override
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn ci
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn update
    Updating '.':
    At revision 0.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn commit
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ ls
    asdf
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svm ci
    sudo: svm: command not found
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn ci
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ ls
    asdf
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn add*
    Unknown command: 'add*'
    Type 'svn help' for usage.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn add *
    A         asdf
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn update
    Updating '.':
    At revision 0.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo nano asdf
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn update
    Updating '.':
    At revision 0.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn ci
    
    Log message unchanged or not specified
    (a)bort, (c)ontinue, (e)dit:
    e
    
    Log message unchanged or not specified
    (a)bort, (c)ontinue, (e)dit:
    asdf update
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn update
    Updating '.':
    At revision 0.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn update
    Updating '.':
    At revision 0.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn ci
    
    Log message unchanged or not specified
    (a)bort, (c)ontinue, (e)dit:
    c
    Authentication realm: <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c                                                                                                 2
    Password for 'root':
    Authentication realm: <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c                                                                                                 2
    Username: sj
    Password for 'sj':
    
    -----------------------------------------------------------------------
    ATTENTION!  Your password for authentication realm:
    
       <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c2
    
    can only be stored to disk unencrypted!  You are advised to configure
    your system so that Subversion can store passwords encrypted, if
    possible.  See the documentation for details.
    
    You can avoid future appearances of this warning by setting the value
    of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
    '/home/ubuntu/.subversion/servers'.
    -----------------------------------------------------------------------
    Store password unencrypted (yes/no)? no
    Adding         asdf
    Transmitting file data .
    Committed revision 1.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn log
    ------------------------------------------------------------------------
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn update
    Updating '.':
    At revision 1.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo nano asdf
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn ci
    
    Log message unchanged or not specified
    (a)bort, (c)ontinue, (e)dit:
    e
    Authentication realm: <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c                                                                                                 2
    Password for 'sj':
    
    -----------------------------------------------------------------------
    ATTENTION!  Your password for authentication realm:
    
       <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c2
    
    can only be stored to disk unencrypted!  You are advised to configure
    your system so that Subversion can store passwords encrypted, if
    possible.  See the documentation for details.
    
    You can avoid future appearances of this warning by setting the value
    of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
    '/home/ubuntu/.subversion/servers'.
    -----------------------------------------------------------------------
    Store password unencrypted (yes/no)? no
    Sending        asdf
    Transmitting file data .
    Committed revision 2.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn log
    ------------------------------------------------------------------------
    r1 | sj | 2014-03-18 17:14:54 +0800 (Tue, 18 Mar 2014) | 1 line
    
    
    ------------------------------------------------------------------------
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo nano asdf
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn ci --username admin --password admin                                                                                                 
    -----------------------------------------------------------------------
    ATTENTION!  Your password for authentication realm:
    
       <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c2
    
    can only be stored to disk unencrypted!  You are advised to configure
    your system so that Subversion can store passwords encrypted, if
    possible.  See the documentation for details.
    
    You can avoid future appearances of this warning by setting the value
    of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
    '/home/ubuntu/.subversion/servers'.
    -----------------------------------------------------------------------
    Store password unencrypted (yes/no)? no
    Sending        asdf
    Transmitting file data .
    Committed revision 3.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn update
    Updating '.':
    At revision 3.
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ svn log
    ------------------------------------------------------------------------
    r3 | admin | 2014-03-18 17:18:05 +0800 (Tue, 18 Mar 2014) | 2 lines
    
    admin changed lot of things.....
    
    ------------------------------------------------------------------------
    r2 | sj | 2014-03-18 17:16:28 +0800 (Tue, 18 Mar 2014) | 2 lines
    
    i changed somthing!!!
    
    ------------------------------------------------------------------------
    r1 | sj | 2014-03-18 17:14:54 +0800 (Tue, 18 Mar 2014) | 1 line
    
    
    ------------------------------------------------------------------------
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo nano helloword.c
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn add helloword.c
    A         helloword.c
    ubuntu@10-4-8-71:/tmp/shit/svnpro$ sudo svn ci
    Authentication realm: <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c                                                                                                 2
    Password for 'admin':
    
    -----------------------------------------------------------------------
    ATTENTION!  Your password for authentication realm:
    
       <svn://10.4.8.71:3690> e0df80d6-353a-43b9-beb9-f13a67ab16c2
    
    can only be stored to disk unencrypted!  You are advised to configure
    your system so that Subversion can store passwords encrypted, if
    possible.  See the documentation for details.
    
    You can avoid future appearances of this warning by setting the value
    of the 'store-plaintext-passwords' option to either 'yes' or 'no' in
    '/home/ubuntu/.subversion/servers'.
    -----------------------------------------------------------------------
    Store password unencrypted (yes/no)? no
    Adding         helloword.c
    Transmitting file data .
    Committed revision 4.
  • 相关阅读:
    HDU --1251
    POJ -- 2436
    POJ -- 3140
    POJ 3107
    POJ -- 2002
    POJ -- 1655
    lintcode154
    lintcode192
    lintcode582
    lintcode901
  • 原文地址:https://www.cnblogs.com/pavkoo/p/3608258.html
Copyright © 2011-2022 走看看