• [转]Linux(centOS6.5)下SVN的安装、配置及开机启动


    1.检查是否已安装

    rpm -qa subversion

    如果要卸载旧版本:

    yum remove subversion

    2.安装

    yum install subversion
    PS:yum install httpd httpd-devel subversion mod_dav_svn mod_auth_mysql(这是安装配合Apache的模块,我暂时还没做,做了再补上,你可以只装subversion,多装了也无所谓)
     
    #确认是否已安装svn模块
    [root@localhost ~]# cd /etc/httpd/modules;ls|grep svn
    mod_authz_svn.so
    mod_dav_svn.so
    如果没有需要安装mod_dav_svn
    #yum -y install mod_dav_svn(我装了)

    3.检查是否安装成功

    svnserve --version

    如果成功会输出版本号

    4.创建仓库目录
    例如:

    mkdir /var/www/svn/repos  (!一级一级创建!)
    5.创建项目
    svnadmin create /var/www/svn/repos
    6.检查是否创建成功
    cd /var/www/svn/repos
    ll
    如果成功,game目录下会多出几个文件夹
    conf,db,format,hooks,locks, README.txt等文件,说明一个SVN库建立完成。

    7、配置代码库

    进入上面生成的文件夹conf下,进行配置

    cd /var/www/svn/repos/conf

    7.1用户密码passwd配置

    vim passwd

    passwd文件的内容如下:

    ### This file is an example password file for svnserve.

    ### Its format is similar to that of svnserve.conf. As shown in the

    ### example below it contains one section labelled [users].

    ### The name and password for each user follow, one account per line.

    [users]

    # harry = harryssecret

    # sally = sallyssecret

    test = 123456789 ##新增用户的用户名和密码

    7.2权限控制authz配置

    vi authz

    目的是设置哪些用户可以访问哪些目录,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
    # [/foo/bar]
    # harry = rw
    # &joe = r
    # * =
    # [repository:/baz/fuz]
    # @harry_and_sally = rw
    # * = r
    [/]
    test = rw
    设置[/]代表根目录下所有的资源

    7.3服务svnserve.conf配置

    vi svnserve.conf

    svnserve.conf文件的内容如下:

    [general]
    #匿名访问的权限,可以是read,write,none,默认为read
    anon-access=none
    #使授权用户有写权限 
    auth-access=write
    #密码数据库的路径 
    password-db=passwd
    #访问控制文件 
    authz-db=authz
    #认证命名空间,subversion会在认证提示里显示,并且作为凭证缓存的关键字 
    realm=/var/www/svn/repos

    防火墙 开放svn端口默认是3690端口

    启动svn服务

    svnserve -d -r /opt/svn/repositories

    8、查看SVN进程

    ps -ef|grep svn|grep -v grep

    返回

    root     20850     1  0 Jul24 ?        00:00:00 svnserve -d -r /opt/svn/repositories

    9、查看SVN监听的端口

    netstat -ln |grep 3690

    10、停止启动SVN

    killall svnserve    #停止 

    svnserve -d -r /opt/svn/repositories  #启动

    11、安装好的svn服务端,默认是不会开机自启动的,每次开机自己启动会很麻烦,我们可以把它设成开机启动
    首先:编写一个启动脚本svn_startup.sh,我放在/root/svn_startup.sh
    #!/bin/bash
    /usr/bin/svnserve -d -r /home/svn/
    这里的svnserve路径保险起见,最好写绝对路径,因为启动的时候,环境变量也许没加载。
    绝对路径怎么查?
    which svnserve

    这里还有可能碰到一个问题,如果你在windows下建立和编写的脚本,拿到linux下,用vi或者vim修改后可能会无法执行,这是文件格式的问题

    vi svn_startup.sh
    输入:set ff 回车
    如果显示的结果不是fileformat=unix
    再次输入
    set ff=unix
    就OK了

    然后修改该脚本的执行权限

    chmod ug+x svn_startup.sh

    或者万能的

    chmod 777 svn_startup.sh

    最后:加入自动运行

    vi /etc/rc.d/rc.local
    在末尾添加脚本的路径,如:
    /root/svn_startup.sh

    现在,你可以重启一下试试了。 不懂得怎么确认成功?败给你了

    ps -ef|grep svnserve
    12、安装svn客户端

    目前最流行的svn客户端非TortoiseSVN莫属

    下载安装

    客户端连接地址:svn://公网或内网的IP地址,有时候需要添加端口号

    用户名/密码: test/123456789  ##要和之前设置的用户名和密码匹配

     注意:

    默认端口为3690,如果该端口被占用,或者需要修改端口,使用下面语句

    svnserve -d -r /opt/svn/repositories --listen-port 3691

  • 相关阅读:
    解析XML
    事务
    js小工具
    plsql用过的流程语句
    查询语句
    存储过程
    用过的CRT命令
    mysql常用命令
    Spirng MVC demo 完整示例01 环境搭建
    jmeter多个http请求串联
  • 原文地址:https://www.cnblogs.com/wuling129/p/4744732.html
Copyright © 2020-2023  润新知