码迷,mamicode.com
首页 > 其他好文 > 详细

SVN服务器搭建

时间:2014-08-29 16:21:48      阅读:488      评论:0      收藏:0      [点我收藏+]

标签:svn服务器搭建

一,准备环境

        RHEL6.4最小化安装(关iptables,关selinux) + ssh + yum

       yum -y install subversion (svn服务器),mysql-server (用于codestriker),httpd

       mod_dav_svn ,mod_perl (用于支持web方式管理SVN服务器 )

       sendmail (用于配置用户提交代码后发邮件提醒)

       wget gcc-c++ make unzip perl* (必备软件包)

       ntsysv vim-enhanced (可选) 

二,配置SVN

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

         mkdir  /home/svn

      2,新建一个版本仓库

          svnadmin create /home/svn/project

      3,初始化版本仓库中的目录

          mkdir project project/servr   project/client   project/test        ##建立临时目录

          svn import project / file:///home/svn/project  -m  comment   ##初始化SVN目录

          rm  -rf  project                 ##删除临时建立的目录

      4,添加用户

              要添加SVN用户非常简单,只需在/home/svn/project/conf/passwd 文件中添加一个
username = passswd”的条目就可以了,为了测试,我添加如下内容:

              [users]
               # harry = harryssecret
               # sally = sallyssecret
                haifeng_1 = 123456 
                haifeng_2 =  123456

       5,修改用户访问策略

                    /home/svn/project/conf/authz 记录用户的访问策略 ,以下为参考:

                               [groups]

                                porject_1 = haifeng_1

                                project_2 = haifeng_2

                               [project:/]

                               @projice_1 = rw

                                * =

                                [project:/server]

                                @project_1 = rw

                                @project_2 = rw

                                * =                            

                                 [project:/client]

                                 @project_1 = rw

                                 @project_2 = rw

                                  * =

                                 [prioject:/doc]

                                 @project_1 = rw

                                 @project_2 = rw

                                    * =

  注意:在添加内容的行首不要有空格,不然会报错:svn: 服务器报告认证错误: Username not found

           6,修改svnserve.conf文件,让用户和策略配置生效,svnserve.conf内容如下:

                     8  [general]

                    12    anon-access = none
                    13    auth-access = write

                    20    password-db = /home/svn/project/conf/passwd

                    27    authz-db = /home/svn/project/conf/authz

            7,启动服务器

                    svnserve -d -r /home/svn

            8,测试服务器

                svn co svn://192.168.6.169/project
认证领域: <svn://192.168.6.169:3690> 2406b06f-d9fa-4165-ac41-e24208ba7188
“root”的密码:
认证领域: <svn://192.168.6.169:3690> 2406b06f-d9fa-4165-ac41-e24208ba7188   

    用户名: haifeng_1
“haifneg_1”的密码:   

A    project/test
A    project/server
A    project/client
取出版本 1。(测试提取成功)     

 

三,配置SVN服务器的HTTP支持

      1,转换SVN服务器的密码

          由于SVN服务器的密码是明文的,HTTP服务器不与支持,所以需要转换HTTP支持的格式。

           因此我写了一个perl脚本来完成这个工作:

     [root@localhost conf]# vim svn.pl

 #!/usr/bin/perl
      use warnings;
      use strict;
 #open the svn passwd file
      open (FILE, "passwd") or die ("Cannot open the passwd file!!!\n");
 #clear the apache passwd file
      open (OUT_FILE, ">webpasswd") or die ("Cannot open the webpasswd file!!!\n");
      close (OUT_FILE);
 #begin
      foreach (<FILE>) {
          if($_ =~ m/^[^#].*=/) {
              $_ =~ s/=//;
             `htpasswd -b webpasswd $_`;
             }
             }

[root@localhost conf]# chmod +x svn.pl (给脚本添加执行权限)

[root@localhost conf]# ./svn.pl
Adding password for user haifeng_1
Adding password for user haifeng_2

现在目录下会多一个webpasswd文件

[root@localhost conf]# ls
authz  passwd  svn.pl  svnserve.conf  webpasswd

      2,修改http的主配置文件,添加SVN服务器的信息

         [root@localhost conf]# vim /etc/httpd/conf/httpd.conf

在文件最后添加:

<Location /project>
                    DAV svn
                    SVNPath /home/svn/project/
                    AuthType Basic
                    AuthName "svn for project"
                    AuthUserFile /home/svn/project/conf/webpasswd
                    AuthzSVNAccessFile /home/svn/project/conf/authz
                    Satisfy all
                    Require valid-user
</Location>

       3,启动HTTP服务

          service httpd start

          chkconfig httpd on

       4,用浏览器访问http://192.168.6.169/project/server

          

 

 

 

 

                                    
                      

本文出自 “岛是海哭碎的心°” 博客,谢绝转载!

SVN服务器搭建

标签:svn服务器搭建

原文地址:http://dihaifeng.blog.51cto.com/8814208/1546447

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!