美文网首页IT必备技能
最全面CentOS上部署SVN(零基础也能学会)

最全面CentOS上部署SVN(零基础也能学会)

作者: 纤_叶芝秋 | 来源:发表于2019-07-15 21:13 被阅读0次

    最近需要进行项目文档管理,但是发现很多文章都没有标明注意点或者对小白友好度不好,希望此文可以帮助零基础的同学快速搭建,言归正传我们开始:

    一、准备阶段

    1、服务器准备:

    购买服务器或者已有服务器的,准备好IP与密码。推荐Windows系统使用Xshell5,Macbook使用iTem2连接服务器,命令如下:

    ssh root@ip地址
    

    然后会提示输入密码,输入即可。Xshell5连接方法更简单,网上方法非常全面

    2、命令准备:

    新服务器可能无法识别某些命令,需要先安装命令(vim和kill即可),命令如下:

    yum install -y vim*  
    yum install psmisc
    

    查看已安装的vim软件包,命令如下:

    rpm -qa | grep vim
    

    二、安装SVN

    1、使用yum安装SVN,命令如下:

    yum -y install subversion
    

    2、新建目录和仓库:在opt目录下新建一个svn目录,目录下新建一个仓库,命令如下:

    mkdir  /opt/svn
    svnadmin create /opt/svn/test/
    

    查看仓库的文件,命令如下:

    cd /opt/svn/test/          #进入仓库目录
    ls                         #展示仓库文件
    

    三、配置SVN

    配置主要分为三步,权限管理、人员管理、人员权限管理。以上其实为三个文件,在/opt/svn/test/conf下管理。首先进入到conf文件夹下面,命令如下:

    cd /opt/svn/test/conf
    ls
    

    输入ls后正常会返回一行“authz passwd svnserve.conf”,即需要配置的三个文件。

    1、配置文件——首先是权限管理文件,命令如下:
    vim svnserve.conf
    

    输入以上vim后会进入一个文件,输入“I”字母后进入编辑状态,找到以下内容,将每行前的#全部去掉即可,去掉后点击“esc”退出编辑状态,按住shift后点击两下英文状态下的zz,退出文件

    anon-access = none                #非授权用户无法访问(也可以设置为read只读)
    auth-access = write               #授权用户有写权限
    password-db = passwd              #密码数据所在目录
    authz-db = authz                  #svn授权文件设置为authz
    

    如图所示:

    ### users have read-only access to the repository, while authenticated
    ### users have read and write access to the repository.
    anon-access = none                  #将“#”去除
    auth-access = write                 #将“#”去除
    ### The password-db option controls the location of the password
    ### database file.  Unless you specify a path starting with a /,
    ### the file's location is relative to the directory containing
    ### this configuration file.
    ### If SASL is enabled (see below), this file will NOT be used.
    ### Uncomment the line below to use the default password file.
    password-db = passwd                #将“#”去除
    ### The authz-db option controls the location of the authorization
    ### rules for path-based access control.  Unless you specify a path
    ### starting with a /, the file's location is relative to the the
    ### directory containing this file.  If you don't specify an
    ### authz-db, no path-based access control is done.
    ### Uncomment the line below to use the default authorization file.
    authz-db = authz                   #将“#”去除
    ### This option specifies the authentication realm of the repository.
    
    2、配置文件——人员管理,命令如下:
    vim passwd
    

    进入文件页面,和上一步编辑方法相同,在[users]中输入以下示例:

    [users]
    # harry = harryssecret
    # sally = sallyssecret
    user1=123                  #输入此行进行人员配置,账号=密码
    ~
    
    3、配置文件——人员权限管理,命令如下:
    vim authz
    

    进入文件页面,和第一步编辑方法相同,在最后输入以下示例:

    [/]
    user1 = rw                    #用户登录账号=权限(r为读w为写)
    
    # [/foo/bar]
    # harry = rw
    # &joe = r
    # * =
    
    # [repository:/baz/fuz]
    # @harry_and_sally = rw
    # * = r
    [/]                    #输入此行
    user1 = rw             #输入此行
    

    四、启动svn服务

    启动SVN,执行如下命令:

    svnserve -d -r /opt/svn/
    

    查看服务是否启动,命令如下:

    ps aux | grep svnserve
    

    五、电脑连接SVN

    一般填写地址为:

    svn://ip地址/test
    svn://ip地址/svn/test
    

    PS:可能遇到的问题

    启动若遇到E000098问题,可以关闭进程重新开启,命令如下:

    killall svnserve
    svnserve -d -r /opt/svn/
    

    若连接SVN一致不成功,可以尝试关闭防火墙,命令如下:

    systemctl stop firewalld.service
    
    firewall-cmd--state                          #查看firewall状态
    systemctl stop firewalld.service             #停止firewall
    systemctl start firewalld.service            #开启firewall
    systemctl disable firewalld.service          #禁止firewall开机启动
    

    以上为全部,如有问题请留言,同时请尊重版权。

    相关文章

      网友评论

        本文标题:最全面CentOS上部署SVN(零基础也能学会)

        本文链接:https://www.haomeiwen.com/subject/oviokctx.html