SVN 服务器的搭建及配置

下面分享一下前段时间我搭建SVN服务器的方法,希望能对需要的人有所帮助;

我把svn服务器的搭建分成两个成次,1、是使用svn协议,这个适用于个人,如果个人作一些自己的项目,这个完全可以满足你的需要;2、是使用http协议+公司的LDAP,这个适用开发团队,它是在1层次的基础上做了进一步的设置

一、svn协议的svn服务搭建

1、下载 Setup-Subversion-1.7.0.msi,这个是svn服务器端的安装包;安装过程非常简单,你可以选择默认的配置,一直下一步就可以了,但要记住安装目录,后面会使用;

     下载地址: http://download.csdn.net/detail/yuanxingyang/6562833

2、创建一个Test库

(1) 首先创建SVN库的目录位置,我的位置是 D:\SubversionRepositories\Test

(2)  进入到刚才安装的Setup-Subversion-1.7.0.ms目录下的bin目录 E:\SVN\1.7.0\bin;

(3) 执行 svnadmin create D:\SubversionRepositories\Test\repo    为了使创建后的SVN库目录结构更清晰,我又加了一层repo目录

(4) 上面的命令执行完,在D:\SubversionRepositories\Test\repo目录下会生产一些文件及文件夹,我们进入到D:\SubversionRepositories\Test\repo\conf目录下

            用文件编辑器打开svnserve.conf,将authz-db = authz和password-db = passwd前面的“#”号去掉,去掉后要保证authz-db = authz和password-db = passwd前不要留有空格,并保存;这个设置是在指定存放用户和用户密码的文件

            用文件编辑器打开authz,在[groups]的下面追加一行cml = test  追加这行的意思是创建了一个cml的用户组,用户组中只有test一个成员,如果有多个成员可以用逗号分隔;

            再在# [/foo/bar]的下面追加两行 [/]和@cml = rw 意思是cml用户组具有svn库根目录的读写权限,设置后的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 [groups] section,
              ###  - an alias defined in a special [aliases] 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
            ### ('').

           [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
         cml = test

        # [/foo/bar]
        # harry = rw
        # &joe = r
        # * =
        [/]
        @cml = rw

       # [repository:/baz/fuz]
       # @harry_and_sally = rw
       # * = r

(5)用编辑器打开passwd文件

          在[users]标签下追加一行test = 123456  意思是设置test用户的密码为123456

3、启动svn服务

  以上几步设置完毕后就完成了svn协议的svn服务的创建及配置,接下来就要启动svn服务

(1)还是要进入到E:\SVN\1.7.0\bin目录下

(2)执行 svnserve.exe -d -r  D:\SubversionRepositories\Test\repos 正常情况下就应该可以启动了

(3)如果要停止svn服务按“ctrl+c”强制终止


4、验证svn库是否创建成功

(1)、安装TortoiseSVN-1.6.5.16974-win32-svn-1.6.5.msi  svn服务的客户端

             下载地址:http://download.csdn.net/detail/yuanxingyang/6562839

(2)、在桌面或任意位置,右键鼠标->TortoiseSVN->Repo-browser

(3)、输入svn://localhost/Test/repo/

(4)、用户名和密码输入刚才创建的test 和123456就可以了;

经过以上几步你就可以进入到你创建的SVN库了;


二、http协议+公司的LDAP服务的SVN库搭建

以下是在《一、svn协议的svn服务搭建》的基础之上进行的,如果要使用http和LDAP,《一、svn协议的svn服务搭建》中“2、创建一个Test库”的(4)步骤就可以不用做

(一)、http协议协议的SVN库的搭建

   1、使用httpd-2.2.22-win32-x86-openssl-0.9.8t.zip安装apache服务,安装路径最好不好安装到C盘,我安装到E:\Apache2.2目录下,安装过程中提示输入的信息可以随意写

         下载地址:http://download.csdn.net/detail/yuanxingyang/6562829

   2、将刚才Setup-Subversion-1.7.0.ms安装目录E:\SVN\1.7.0\bin下的mod_dav_svn.so和mod_authz_svn.so文件复制到apache的安装目录E:\Apache2.2\modules下面

   3、将LoadModule dav_module modules/mod_dav.so和LoadModule dav_fs_module modules/mod_dav_fs.so前面的“#”号去掉,不要留空格

   4、在LoadModule 模块部分的最后追加以下两行

    LoadModule dav_svn_module modules/mod_dav_svn.so

    LoadModule authz_svn_module modules/mod_authz_svn.so

   5、将ServerAdmin设成服务器管理员的邮箱;ServerAdmin zhu_ym@neusoft.com

   6、将ServerName设成   ServerName 10.1.1.246:80

   7、在文件的末尾追加一下信息:

<Location /subversion/Test>
        DAV svn
        SVNParentPath D:\SubversionRepositories\Test
        SVNListParentPath On
        AuthType Basic
        AuthName "test1_CODE repos"
        AuthzSVNAccessFile D:\SubversionRepositories\Test\authz
        AuthUserFile D:\SubversionRepositories\Test\passwd
        Require valid-user
</Location>

   8、把上次创建好的D:\SubversionRepositories\Test\repo\conf\authz用户文件复制到D:\SubversionRepositories\Test目录下,目录随意,只要和7中的AuthzSVNAccessFile D:\SubversionRepositories\Test\authz保持一致及可

   9、密码文件不能使用上次的创建的密码文件,因为http使用的是加密密码文件,我们要进入到apache的安装目录下E:\Apache2.2\bin,运行htpasswd.exe -c  D:\SubversionRepositories\test1\passwd test

        注意要和7中AuthUserFile D:\SubversionRepositories\Test\passwd的目录位置一致;第一次因为没有passwd文件,所以要添加-c参数,以后添加新用户和修改用户密码时就不要添加-c参数了

   10、重启apache服务,如果重启服务启动不了可以重启一下机器试试,不行就看apache安装目录E:\Apache2.2\logs下的log信息,如果没意外重启机器应该可以使apache正常运行

   11、在桌面或任意位置,右键鼠标->TortoiseSVN->Repo-browser输入http://10.1.1.246//subversion/Test/repo

   12、用户名输入test和你刚才创建的新密码就可以了

(二)连接LDAP服务器

有的公司有自己的LDAP服务器来统一管理公司成员的用户密码,下面介绍一下如何配置apache来与LDAP服务器关联

1、“(一)、http协议协议的SVN库的搭建“中的第9步可以省略,因为密码要使用公司的LDAP服务器来管理

2、将“(一)、http协议协议的SVN库的搭建“中的第7步,追加信息修改为

<Location /subversion/Test>
    DAV svn
    SVNParentPath D:\SubversionRepositories\Test
    SVNListParentPath On

    AuthzSVNAccessFile D:\SubversionRepositories\Test\authz
    AuthBasicProvider ldap
    AuthType Basic
    AuthzLDAPAuthoritative off
    AuthName "<Test代码库>"

    AuthLDAPURL "ldap://*****.com:****/DC=****,DC=internal?sAMAccountName?sub?(objectClass=*)" NONE
    AuthLDAPBindDN "CN=***,ou=people,DC=*****,DC=internal"
    AuthLDAPBindPassword "*****"

    Require valid-user
</Location>


 



  

   






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值