系统环境
        RHEL5.4最小化安装(关iptables,关selinux) + ssh + yum

一,安装必须的软件包.
        yum 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/server project/client project/test (建立临时目录)
                # svn import project/ file:///home/svn/project -m "初始化SVN目录"
                # rm -rf project (删除临时建立的目录)

4,添加用户
                要添加SVN用户非常简单,只需在/home/svn/project/conf/passwd文件添加一个形如“username=password"的条目就可以了.为了测试,我添加了如下内容:
                [users]
                # harry = harryssecret
                # sally = sallyssecret
                pm = pm_pw
                server_group = server_pw
                client_group = client_pw
                test_group = test_pw

5,修改用户访问策略
                /home/svn/project/conf/authz记录用户的访问策略,以下是参考:
                        [groups]
                        project_p = pm
                        project_s = server_group
                        project_c = client_group
                        project_t = test_group
                        
                        [project:/]
                        @project_p = rw
                        * =
                        
                        [project:/server]
                        @project_p = rw
                        @project_s = rw
                        * =
                        
                        [project:/client]
                        @project_p = rw
                        @project_c = rw
                        * =
                        
                        [project:/doc]
                        @project_p = rw
                        @project_s = rw
                        @project_c = rw
                        @project_t = rw
                        * =
                以上信息表示,只有pm有根目录的读写权,server_group能访问server目录,client_group能访问client目录,所有人都可以访问doc目录.

6,修改svnserve.conf文件,让用户和策略配置升效.
                svnserve.conf内容如下:
                        [general]
                        anon-access = none
                        auth-access = write
                        password-db = /home/svn/project/conf/passwd
                        authz-db = /home/svn/project/conf/authz

7,启动服务器
                # svnserve -d -r /home/svn

8,测试服务器
                # svn co svn://192.168.60.10/project
                Authentication realm: <svn://192.168.60.10:3690> 92731041-2dae-4c23-97fd-9e1ed7f0d18d
                Password for 'root': 
                Authentication realm: <svn://192.168.60.10:3690> 92731041-2dae-4c23-97fd-9e1ed7f0d18d
                Username: server_group
                Password for 'server_group': 
                svn: Authorization failed ( server_group没用根目录的访问权 )

# svn co svn://192.168.60.10/project
                Authentication realm: <svn://192.168.60.10:3690> 92731041-2dae-4c23-97fd-9e1ed7f0d18d
                Password for 'root': 
                Authentication realm: <svn://192.168.60.10:3690> 92731041-2dae-4c23-97fd-9e1ed7f0d18d
                Username: pm
                Password for 'pm': 
                A    project/test
                A    project/server
                A    project/client
                Checked out revision 1.  ( 测试提取成功 )

# cd project/server
                # vim main.c
                # svn add main.c 
                # svn commit main.c -m "测试一下我的C程序,看什么看,不行啊??"
                Adding         main.c
                Transmitting file data .
                Committed revision 2.  ( 测试提交成功 )

三,配置SVN服务器的HTTP支持
        1,转换SVN服务器的密码
                由于SVN服务器的密码是明文的,HTTP服务器不与支持,所以需要转换成HTTP支持的格式。我写了一个Perl脚本完成这个工作.
                脚本内容如下:
                # cd /home/svn/project/conf/
                # cat PtoWP.pl 
                #!/usr/bin/perl
                # write by huabo, 2009-11-20
                
                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 $_`;
                    }
                }

# ./PtoWP.pl ( 先给该脚本加可执行权限,然后执行以转换密码 )
                Adding password for user pm
                Adding password for user server_group
                Adding password for user client_group
                Adding password for user test_group
                现在目录下会多一个webpasswd文件。

2,修改httpd.conf,添加关于SVN服务器的内容
                编辑/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,启动HTTPD服务器
                # service httpd restart
                Stopping httpd:                                            [FAILED]
                Starting httpd:                                            [  OK  ]

4,用浏览器访问http://192.168.60.10/project/server/测试
                测试结果如下图所示:

( 测试成功 )

四,配置邮件提醒支持
        1,安装Perl模块Module::Build
                # wget http://search.cpan.org/CPAN/authors/id/D/DA/DAGOLDEN/Module-Build-0.36_11.tar.gz
                # tar xvf Module-Build-0.36_11.tar.gz 
                # cd Module-Build-0.36_11
                # perl Build.PL 
                # ./Build 
                # ./Build test
                # ./Build install
                # cd ..

2,安装Perl模块Authen::SASL
                # wget http://search.cpan.org/CPAN/authors/id/G/GB/GBARR/Authen-SASL-2.15.tar.gz
                # tar xvf Authen-SASL-2.15.tar.gz 
                # cd Authen-SASL-2.15
                # perl Makefile.PL 
                # make test
                # make install
                # cd ..

3,安装Perl模块Net::SMTP_auth
                # wget http://search.cpan.org/CPAN/authors/id/A/AP/APLEINER/Net-SMTP_auth-0.08.tar.gz
                # tar xvf Net-SMTP_auth-0.08.tar.gz 
                # cd Net-SMTP_auth-0.08
                # perl Makefile.PL 
                # make test
                # make install
                # cd ..

4,安装Perl模块SVN::Notify
                # wget http://search.cpan.org/CPAN/authors/id/D/DW/DWHEELER/SVN-Notify-2.80.tar.gz
                # tar xvf SVN-Notify-2.80.tar.gz 
                # cd SVN-Notify-2.80
                # perl Build.PL 
                # ./Build 
                # ./Build test
                # ./Build install
                # cd ..

5,启动邮件服务器
                # service sendmail restart
                Shutting down sendmail:                                    [FAILED]
                Starting sendmail:                                         [  OK  ]
                Starting sm-client:                                        [  OK  ]

6,配置自动发邮件脚本
                修改post-commit脚本,以支持邮件通知功能.
                # cd /home/svn/project/hooks/
                # vim post-commit
                内容如下:
                #!/bin/sh
                REPOS="$1"
                REV="$2"
                
                /usr/bin/svnnotify --repos-path "$1" --revision "$2" --to caodaijun@pica.com --from caodaijun@feinno.com --handler "HTML::ColorDiff"  --with-diff --smtp localhost --smtp-user root --smtp-pass 5201314318 -c "UTF-8" -g zh_CN -o raw --svnlook /usr/bin/svnlook --subject-prefix '[SVN Update]'
                (to参数代表接收邮件的地址,可以有多个,当你有多个老大的时候,这就很重要了,:)。from参数是虚拟的,代表你的发送地址,一般情况下,这个参数 不重要,但如果接收者的邮件服务器有反垃圾邮件的功能,需要判定源地址的话,这个参数是否合法就显得很重要了)
                再给该脚本添加可执行权限
                # chmod +x post-commit

7,再次提交时,就会给指定邮件地址发信了。
                如下图所示:

五,其它常用配置 
        1,强制写log脚本
                配置pre-commit文件,要求用户每次更新文件都必须写log.
                # cd /home/svn/project/hooks/
                # vim pre-commit
                文件内容如下:
                #!/bin/sh
                REPOS="$1"
                TXN="$2"
                SVNLOOK=/usr/bin/svnlook
                LOGMSG=`$SVNLOOK log -t "$TXN" "$REPOS" | grep "[a-zA-Z0-9]" | wc -c`
                if [ "$LOGMSG" -lt 5(要求的log长度,依实际需要修改) ];
                then
                 echo -e "\nEmpty log message not allowed. Commit aborted!" 1>&2
                 exit 1
                fi

配置完成后,给本件加上可执行权限。再提交代码时,就必须按要求写注释了,:)

2,可修改log脚本
                配置pre-revprop-change文件,此文件在show log中修改log时会运行,得到修改的权限,否则会报错:DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent. At least one property change failed; repository is unchanged
                # cd /home/svn/project/hooks/
                # vim pre-revprop-change
                文件内容如下:
                REPOS="$1"
                REV="$2"
                USER="$3"
                PROPNAME="$4"
                if ["$PROPNAME" = "svn:log"];then exit 0;fi
                exit 1

配置完后加可执行权限升效。

六,备份管理
        svn服务器的定期备份是很重要的,最简单的方式是定时备份仓库目录。
        1,新建备份目录
                # mkdir /opt/project_backup

2,编写备份脚本
                # cd /home/svn/
                # vim project_backup.sh

内容如下:
                #!/bin/bash
                #write by huabo, 2009-11-20
                
                cd /home/svn
                now=`/bin/date +%Y%m%d`
                /bin/tar czvf "project_backup_$now.tar.gz" project/ && rm -rf /opt/project_backup/* && /bin/mv project_backup_*.tar.gz /opt/project_backup/
                if [ $? == 0 ]
                then
                    result="OK!!"
                else
                    result="False!!"
                fi
                
                #send mail to administrator
                /bin/mail caodaijun@pica.com -s "project_backup_$now" <<MESSAGE
                Result: `/bin/echo $result`
                MESSAGE

给该脚本添加可执行权限。

3,设定每天定时执行该脚本.
                # crontab -e
                输入如下内容:
                0 23 * * * /home/svn/project_backup.sh
                表示每天晚上23点运行此脚本。

经过以上三步操作,就可以自动备份SVN资料了,且不论备份是否成功,都会给用户发送邮件信息。

七,用svnstat分析SVN数据.
        1,安装JAVA
        svnstat是JAVA应用程序,需要先安装JAVA环境。
        下载jre,URL: http://javadl.sun.com/webapps/download/AutoDL?BundleId=39484
        安装:
                # chmod +x jre-6u20-linux-i586-rpm.bin 
                # ./jre-6u20-linux-i586-rpm.bin

2,下载svnstat
                # wget http://downloads.sourceforge.net/project/svnstat/svnstat/Release-1.0/SvnStat-1.0.zip?use_mirror=jaist
                # unzip SvnStat-1.0.zip

3,更新代码
                # pwd
                /root

# svn co svn://192.168.60.10/project
                A    project/test
                A    project/server
                A    project/server/main.c
                A    project/client
                Checked out revision 5.

4,生成svnstat数据
                # svn log project -v --xml --non-interactive > project.log
                # cd SvnStat-1.0
                # java -classpath SvnStat-all.jar de.agentlab.svnstat.SvnStat -jar SvnStat-all.jar -r /root/project.log -d /var/www/html/

5,用浏览器登录即可看到许多统计出来的图表。大致如下图所示:

(俺的测试代码很少,生成的图不成样子,拿官方的图来充当一下,:))

八,用statsvn分析SVN数据
        1,下载statsvn
                # wget http://downloads.sourceforge.net/project/statsvn/statsvn/0.7.0/statsvn-0.7.0.zip?use_mirror=jaist
                # unzip statsvn-0.7.0.zip 
                # cd statsvn-0.7.0

2,生成statsvn数据
                # mkdir /var/www/html/statsvn
                # java -jar statsvn.jar -verbose -output-dir /var/www/html/statsvn/ /root/project.log /root/project

3,用浏览器测测试效果如下图:

九,配置codestriker.
        1.安装codestriker依赖的perl包.
                # perl -MCPAN -e 'install "Template"'
        
        2.下载codestriker
                # wget http://downloads.sourceforge.net/project/codestriker/codestriker/1.9.10/codestriker-1.9.10.tar.gz?use_mirror=jaist&ts=1279246587
                # mkdir /var/www/codestriker
                # cd /var/www/codestriker
                # tar xvf /path/codestriker-1.9.10.tar.gz 
                # chown -R apache.apache codestriker-1.9.10
                
        3.配置数据库
                # service mysqld restart
                # mysql -uroot mysql
                    执行:
                        CREATE DATABASE codestrikerdb CHARACTER SET utf8;
                        GRANT SELECT,INSERT,UPDATE,DELETE,INDEX,ALTER,CREATE,DROP,REFERENCES ON codestrikerdb.* TO codestriker@localhost IDENTIFIED BY 'cspasswd';
                        FLUSH PRIVILEGES;
                        quit
        
        4.配置codestriker
                # cd codestriker-1.9.10/
                # vim codestriker.conf
                    注意以下几点(详细可查看codestriker的安装文档)
                    a.数据库的用户名密码要配对
                    b.svn的数据仓库要配对,我的如下:
                         @valid_repositories =
                             (
                              'svn:file:///home/svn/project',
                             )
        
        5.执行codestriker的安装脚本
                # cd bin/
                # ./install.pl
        
        6.配置http支持
                # vim /etc/httpd/conf/httpd.conf
                    在最后面加上如下内容:
                        Alias /codestriker/  /var/www/codestriker/codestriker-1.9.10/cgi-bin/
                        Alias /codestrikerhtml/  /var/www/codestriker/codestriker-1.9.10/html/
                        
                        <Directory "/var/www/codestriker/codestriker-1.9.10/cgi-bin/">
                           SetHandler perl-script
                           PerlHandler ModPerl::Registry
                           Options +ExecCGI
                        </Directory>
                        
                        <Directory "/var/www/codestriker/codestriker-1.9.10/html/">
                           AllowOverride None
                           Allow from all
                        </Directory>
        
        7.重启HTTP服务器
                # service httpd restart 
        
        8.在浏览器中输入http://192.168.60.10/codestriker/codestriker.pl即可访问,如下图:

linux下搭建SVN服务器完全手册-很强大!!!!!的更多相关文章

  1. linux下搭建SVN服务器完全手册

    原文:http://www.cnblogs.com/wrmfw/archive/2011/09/08/2170465.html 系统环境        RHEL5.4最小化安装(关iptables,关 ...

  2. linux下搭建SVN服务器完全手册【转】

    转自:http://blog.csdn.net/bullbat/article/details/9115559 系统环境        RHEL5.4最小化安装(关iptables,关selinux) ...

  3. linux下搭建SVN服务器完全手册【摘抄】

    系统环境        RHEL5.4最小化安装(关iptables,关selinux) + ssh + yum 一,安装必须的软件包.        yum install subversion ( ...

  4. Linux下搭建SVN服务器及自动更新项目文件到web目录(www)的方法

    首先搭建SVN服务器 1,安装SVN服务端 直接用apt-get或yum安装subversion即可(当然也可以自己去官方下载安装) sudo apt-get install subversion   ...

  5. SVN:linux下搭建svn服务器

    转载:https://www.cnblogs.com/puloieswind/p/5856326.html 1. 安装SVN服务器: 检查是否已安装 # rpm -qa subversion 安装SV ...

  6. 在Linux下搭建SVN服务器

    svn不仅仅可以用于程序开发,还可以做很多事情,例如备份文档. CentOS下:安装 这样同一台服务器便可以运行多个svnserver了 检查端口 注:如果修改了svn配置,需要重启svn服务 -j ...

  7. Linux下搭建svn服务器(转)

    原文地址:http://blog.163.com/longsu2010@yeah/blog/static/173612348201202114212933/ 安装步骤如下: 1.yum install ...

  8. linux下搭建svn服务器

    安装步骤如下: 1.yum install subversion   2.输入rpm -ql subversion查看安装位置,如下图:   我们知道svn在bin目录下生成了几个二进制文件. 输入 ...

  9. Linux下搭建SVN服务器遇到的问题及解决方法,

    1.checkout时,提示:URL svn://192.168.1.99/svntest doesn't exist... 奇怪,怎么会提示库不存在呢?肯定是哪里配置问题.后来尝试了半天,也在网上搜 ...

随机推荐

  1. Html.Partial和Html. RenderPartial

    圣殿骑士-蓝剑行动 Html.Partial和Html. RenderPartial用法 Html.Partial和Html. RenderPartial用法 Html.partial和RenderP ...

  2. swift UI特殊培训38 与滚动码ScrollView

    有时我们适合页面的全部内容,我们需要使用ScrollView,额外的内容打通滚动. 什么样的宽度和高度首先,定义,健身器材轻松. let pageWidth = 320 let pageHeight ...

  3. JS数据绑定模板artTemplate试用

    之前写JS绑定数据曾经用过tmpl库,虽然功能比较强大但是感觉不是很轻量,对于相对简单的数据需求显得有些臃肿.而Ajax返回数据自己拼接html的方式又显得不够高端,因此今天看了一篇介绍artTemp ...

  4. Android——保存并读取文件

    Context.MODE_PRIVATE:为默认操作模式,代表该文件是私有数据,仅仅能被应用本身訪问,在该模式下,写入的内容会覆盖原文件的内容,假设想把新写入的内容追加到原文件里.能够使用Contex ...

  5. 使用 CodeIgniter 创建一个简单的 Web 站点

    原文:使用 CodeIgniter 创建一个简单的 Web 站点 参考源自: http://www.ibm.com/developerworks/cn/web/wa-codeigniter/index ...

  6. 使用 CodeIgniter 框架快速开发 PHP 应用(三)

    原文:使用 CodeIgniter 框架快速开发 PHP 应用(三) 分析网站结构既然我们已经安装 CI ,我们开始了解它如何工作.读者已经知道 CI 实现了MVC式样. 通过对目录和文件的内容进行分 ...

  7. Spring4 SpringMVC Hibernate4 Freemaker 集成示例

    变更更正(2014-05-30 13:47:22):一些IDE在web.xml我们会报告这个错误: cvc-complex-type.2.4.a: Invalid content was found ...

  8. 怪异php 语法, 求解!

    查找php馍用来推断是否串串返回值和方法 strpos很奇怪. 请看下面的语句: echo "A1: ".(strpos("csd","c" ...

  9. HDU 4793 2013 Changsha Regional Collision[简单的平面几何]

    圆形奖章给定半径的半径和圆形区域.另一个硬币的半径,然后在桌面上平稳.给定硬币的速(的大小和方向,vx,vy)和坐标(奖牌同心圆形区域,圆和心脏为源),Q币在一个圆形区域和多少下滑(不管是什么圆形区域 ...

  10. centos7的安装

    初装centos7还是在九月份,那时候关于win7 下centos7硬盘安装的资料很少,现在就好多, 在这里备份下东西吧 首先是安装的时候,关于找从那个地方找image的问题. hda ,sda分别表 ...