• Subversion版本控制 — 安装(一)


    Subversion简介

    Subversion是一个自由,开源的版本控制系统。在Subversion管理下,文件和目录可以超越时空。
    Subversion将文件存放在中心版本库里。这个版本库很像一个普通的文件服务器,不同的是,它可以
    记录每一次文件和目录的修改情况。这样就可以藉此将数据恢复到以前的版本,并可以查看数据的
    更改细节。正因为如此,许多人将版本控制系统当作一种神奇的“时间机器”[1] 。
    subversion(svn)是近年来崛起的版本管理软件,是cvs的接班人。目前,绝大多数开源软件都使用
    svn作为版本管理软件。 

    采用:拷贝 — 修改 — 合并 方案。
    而不是:锁定 — 修改 — 解锁 方案。

    Windows下的SVN客户端
    TortoiseSVN是Windows下的SVN(Subversion)版本控制系统的一个免费开源客户端,可以超越时间
    的管理文件和目录。
    文件保存在中央版本库,除了能记住文件和目录的每次修改以外,版本库非常像普通的文件服务器。
    用户可以将文件恢复到过去的版本,并且可以通过检查历史知道数据做了哪些修改,谁做的修改。

    SVN独立服务器

    官网:http://subversion.apache.org
    安装文件:
    subversion-1.6.18.tar.bz2
    subversion-deps-1.6.18.tar.bz2
    注意,需要有如下包:
    openssl
    openssl-devel

    (一)安装前准备

    wget http://subversion.apache.org/download/subversion-1.6.18.tar.bz2
    wget http://subversion.apache.org/download/subversion-deps-1.6.18.tar.bz2
    确定openssl、openssl-devel包已经安装,如:rpm -qa | grep openssl

    (二)编译和安装

    1. 解压,要在同一个目录下:
    tar -zxvf subversion-1.6.18.tar.bz2 -C /usr/local/subversion-1.6.18
    tar -zxvf subversion-deps-1.6.18.tar.bz2 -C /usr/local/subversion-1.6.18 

    2. 编译和安装
    ./configure --prefix=/usr/local/subversion-1.6.18
    make && make install

    3. 产生的可执行文件
    安装成功后,在/usr/local/bin/中,会有如下可行性文件:
    svn svnadmin svndumpfilter svnlook svnserve svnsync svnversion

    4. 确定安装成功
    svnserve --version,打印出版本信息则安装成功

    (三)建立版本库

    1. 建立SVN的根目录,此目录下可包含多个项目
    mkdir -p /opt/svn 

    2. 建立一个项目的版本库
    mkdir -p /opt/svn/svntest
    svnadmin create /opt/svn/svntest 

    svnadmin说明:
    Subversion keeps a single copy of the master sources. This copy is called the source
    repositary. It contains all the information to permit extracting previous versions of those
    files at any time.
    svnadmin — subversion repositary administration tool 

    3. 修改配置文件
    cd /opt/svn/svntest/conf
    目录下有三个文件:
    authz — 权限控制,哪些用户可以访问哪些目录
    passwd — 用户名和密码配置
    svnserve.conf — svnserve服务器的配置 

    3.1) 配置authz
    vi authz
    [svntest:/]
    zhangskd = rw
    # 给svntest的版本库repositary添加一个用户zhangskd,权限为读写。 

    3.2) 配置passwd
    vi passwd
    [users]
    zhangskd = 123456
    #用户名=密码 

    3.3) 配置svnserve.conf
    vi svnserve.conf
    取消一些注释
    [general]
    anon-access = none                  #非授权用户无法访问
    auth-access = write                   #授权用户有写权限
    password-db = passwd           #密码数据所在目录
    authz-db = authz                         #认证数据所在目录 

    (四)启动SVN的独立服务器

    1. 启动svnserve,并制定SVN的根目录
    svnserve -d -r /opt/svn 

    2. 查看服务是否启动
    ps aux | grep svnserve
    netstat -tunlp | grep svnserve 

    svnserve的几个参数说明:
    svnserve — serve for the svn repository access method
    svnserve allows access to subversion repositaries using the svn network protocol.
    -d, --daemon
            Causes svnserve to run in daemon mode. svnserve backgrounds itself and accepts
            and serves TCP/IP connections on the svn port (3690, by default).
    --listen-port=port
            Causes svnserve to listen on port when run in daemon mode.
    -r root, --root=root
            Sets the virtual root for repositaries served by svnserve. The pathname in URLs
            provided by the client will be interpreted relative to this root, and will not be allowed
            to escape this root. 

    (五)测试SVN的独立服务器

    1. Windows下用TortoiseSVN测试
    新建一个svntest目录,右键选择Checkout,在URL of repositary中输入svnserve的IP和
    访问项目的名字:
    svn://192.168.1.1/svntest
    然后跳出验证窗口,输入配置的用户名和密码即可。
    注意:如果服务器没关闭防火墙就会出现不能连接!
    service iptables stop

    2. CentOS下测试
    svn checkout svn://192.168.1.1/svntest

    基于Apache的SVN服务器

     

    (一)安装前准备

    1. Apache服务器安装包
    wget http://labs.mop.com/apache-mirror/httpd//httpd-2.4.2.tar.bz2
    wget http://labs.mop.com/apache-mirror/httpd//httpd-2.4.2-deps.tar.bz2

    2. apr和apr-util安装包
    wget http://www.fayea.com/apache-mirror/apr/apr-1.4.6.tar.bz2
    wget http://www.fayea.com/apache-mirror/apr/apr-util-1.4.1.tar.bz2

    (2)安装Apache

    1. 安装apr
    tar -jxvf apr-1.4.6.tar.bz2 -C /usr/src/
    cd /usr/src/apr-1.4.6
    ./configure --prefix=/usr/local/apr
    make
    make install 

    2. 安装apr-util
    tar -jxvf apr-util-1.4.1.tar.bz2 -C /usr/src
    cd /usr/src/apr-util-1.4.1
    ./configure --with-apr=/usr/local/apr
    make
    make install 

    3. 安装Apache
    tar -jxvf httpd-2.4.2.tar.bz2 -C /usr/src
    tar -jxvf httpd-2.4.2-deps-tar.bz2 -C /usr/src
    cd /usr/src/httpd-2.4.2
    ./configure \
    --prefix=/usr/local/apache2 \
    --with-apr=/usr/local/apr/bin/apr-1-config \
    --with-apr-util=/usr/local/apr/bin/apu-1-config \
    --enable-modules-so \
    --enable-dav \
    --enable-maintainer-mode \
    --enable-rewrite
    make
    make install 

    默认安装目录为/usr/local/apache2。
    安装后启动:apachectl -k start
    设置为开机启动:chkconfig httpd on 

    如果出现错误:

    httpd: Could not reliably determine the server's fully qualified domain name,
    using ** for ServerName
    在/etc/httpd/conf/httpd.conf中取消ServerName的注释即可。

    验证Apache是否安装成功:
    启动浏览器,输入http://localhost/,看是否有Apache的测试页面。

    (三)安装subversion

    由于用源码包安装会遇到版本和兼容性问题,比较不方便,以下用yum来安装。
    1. 安装
    yum install subversion mod_dav_svn
    其中:subversion为主程序包
                mod_dav_svn是apache用到的功能模块 

    (四)创建SVN版本库

    mkdir -p /opt/svn #根目录
    svnadmin create /opt/svn/svn/svntest #svntest项目
    #修改svn库的所有者,readable and writable by apache user.
    chown -R apache.apache svntest
    chcon -R -t httpd_sys_content_t svntest
    #change file SELinux security context. labelled with the 'httpd_sys_content_t'
    #if using SELinux 

    (五)创建SVN用户文件

    #创建用户文件passwd,添加一个用户
    # -c表示创建,-m采用MD5加密密码
    htpasswd -cm passwd username
    会显示:
    New password:
    Re-type new passwd:
    Adding password for user username 
    如果还需要添加用户:
    htpasswd -m passwd anotherusername
    只有第一次才需要-c 
    删除用户:
    htpasswd -D passwd username 

    (六)创建SVN访问权限控制文件

    cd /opt/svn
    touch authz
    编辑authz:
    [group]
    group1=user1, user2 
    [svntest:/]
    @group=r
    user1=rw 

    (七)配置Apache以支持SVN

    Apache中SVN的配置文件为:/etc/httpd/conf.d/subversion.conf
    其中必须有以下两行,没有则自行添加:
    LoadModule dav_svn_module modules/mod_dav_svn.so
    LoadModule authz_svn_module modules/mod_authz_svn.so 

    添加:
    <Location /svn> 
        DAV svn
        SVNParentPath /opt/svn   #svn的根目录
        AuthType Basic                  #Basic认证方式
        AuthName "Subversion"   #认证时显示的信息
        AuthUserFile /opt/svn/passwd   #用户文件
        AuthzSVNAccessFile  /opt/svn/authz   #访问权限控制文件
        Require valid-user    #要求真实用户,不能匿名
    </Location> 

    (八)测试

    service httpd start
    在浏览器中输入URL:http://localhost/svn/svntest/
    会弹出一个认证窗口,通过认证后即可访问svntest项目。 

    (九)验证方式

    Basic和Digest都是Web应用可采用的验证机制。
    Basic验证使用原文传送秘密,所以应该只通过加密的传输途径发送,如HTTPS。
    Digest保证不会通过纯文本发送证书,如果使用没有加密的HTTP,还希望达到最大
    安全性的时候,摘要验证便具有很高的吸引力。
    在/etc/httpd/conf.d/subversion.conf中:
    AuthType Digest
    AuthName "Subversion"
    在/opt/svn下
    格式:htdigest -c passwdfile realm username
    htdigest -c digest "Subversion" username
    htdigest digest "Subversion" anotherusername 

    (十)问题解决

    http://localhosts/svn/
    显示:
    Forbidden
    You don't have permission to access /svn/ on this server.
    决绝措施:
    在/opt/svn/authz中增加权限:
    [/]
    username = r
    在/etc/httpd/conf.d/subversion.conf中修改
    <location /svn>改成<location /svn/>
    SVNParentPath /opt/svn改成SVNParentPath /opt/svn/
    添加:SVNListParentPath on

    OK,重启httpd后再访问就有:Collection of Repositories

    Author

    zhangskd @ csdn

    Reference

    [1] http://baike.baidu.com/view/429581.htm 百度百科,很详细的介绍。
    [2] http://www.cnblogs.com/sunyubo/archive/2010/05/25/2282164.html linux下svn客户端安装。
    [3] http://ybhanxiao.iteye.com/blog/1280999 linux下SVN独立服务器安装。

  • 相关阅读:
    30秒懂SQL中的join(2幅图+30秒)
    MySQL字符串连接函数
    php 月初,月末时间大统计
    php判断中文,英文, 数字
    配置linux----------------ip
    配置samba
    Python的MySQLdb模块安装
    python 之 PIP 安装
    linux之svn
    vue之computed(计算属性)
  • 原文地址:https://www.cnblogs.com/aiwz/p/6333377.html
Copyright © 2020-2023  润新知