• centos7+apache+svn配置 踩坑,注意权限问题。apache应用目录checkout应用 必须用这个命令:svn co file:///home/svn/test/ test ,通过svn add * &&commit 及任意修改都是不行的


    • 阅读帮助
      命令提示符
      [root@server-002 ~]# 表示当前服务root用户执行的命令
      [svn@server-002 ~]$ 表示普通用户svn执行的命令
      [root@localhost ~]# 表示其它服务器的root用户

    系统配置

    CPU: 2核
    内存: 8G
    硬盘: 1T
    服务器OS: CentOS7
    服务器IP: 192.168.1.2


    服务简介

    SVN 版本库 server


    服务管理

    管理用户命令说明
    svn sudo systemctl start httpd 启动服务
    svn sudo systemctl stop httpd 停止服务
    root systemctl start httpd 启动服务
    root systemctl stop httpd 启动服务

    服务安装和配置

    安装SVN服务

    1. 创建svn用户
      [root@server-002 ~]# useradd svn
      [root@server-002 ~]# passwd svn
    2. 查看是否已经安装svn
      [root@server-002 ~]# rpm -qa subversion
    3. 如果没有,直接第4步,如果有,先卸载
      [root@server-002 ~]# rpm remove subversion -y
    4. 创建svn.repo文件
      [root@server-002 ~]# vi /etc/yum.repos.d/svn.repo
    [SVN]
    name=SVN Repo
    baseurl=http://opensource.wandisco.com/centos/7/svn-1.9/RPMS/$basearch/
    enabled=1
    gpgcheck=0
    • 1
    • 2
    • 3
    • 4
    • 5
    1. 执行yum安装svn
      [root@server-002 ~]# yum install subversion -y
    2. 防火墙打开svn默认的3690端口
      [root@server-002 ~]# firewall-cmd –zone=public –add-port=3690/tcp –permanent
      [root@server-002 ~]# firewall-cmd –reload

    迁移SVN数据

    1. ssh到原SVN服务器备份旧SVN数据仓库
      [root@localhost ~]# svnadmin dump /var/www/svn/latRepo > /svndump/latRepo.dump
    2. 将备份copy到新的SVN服务器
      [root@localhost ~]# scp /svndump/*.dump svn@192.168.1.2:~/dump
    3. 回到新的SVN服务器,登陆svn用户,创建版本库
      [svn@server-002 ~]$ svnadmin create latRepo
    4. 恢复版本库
      [svn@server-002 ~]$ svnadmin load latRepo < dump/latRepo.dump
    5. 创建日志目录/home/svn/logs
      [svn@server-002 ~]$ mkdir logs
    6. 创建配置目录/home/svn/conf
      [svn@server-002 ~]$ mkdir conf
    7. 创建配置文件/home/svn/conf/svnserve.conf(示例)
      [svn@server-002 ~]$ vim conf/svnserve.conf
    [general]
    anon-access = read
    auth-access = write
    password-db = passwd
    authz-db = authz
    [sasl]
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    1. 创建用户文件/home/svn/conf/passwd(示例)
      [svn@server-002 ~]$ vim conf/passwd.conf
    [users]
    hezhigang=hezhigang
    shenfu=shenfu
    yangshuaifei=yangshuaifei
    • 1
    • 2
    • 3
    • 4
    1. 创建认证文件/home/svn/conf/authz(示例)
      [svn@server-002 ~]$ vim conf/authz
    [groups]
    lse = hezhigang, shenfu, yangshuaifei
    
    [/]
    spancer = rw
    
    [latRepo:/]
    @lse = rw
    * =
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    配置服务管理脚本

    1. 启动脚本start.sh
      [svn@server-002 ~]$ vim start.sh
    #!/bin/bash
    svnserve -d -r /home/svn --config-file=/home/svn/conf/svnserve.conf --log-file=/home/svn/logs/svn.log
    • 1
    • 2
    1. 停止脚本stop.sh
      [svn@server-002 ~]$ vim start.sh
    #!/bin/bash
    PID=$(ps -ef | grep svnserve | grep -v grep | awk '{ print $2 }')
    if [ -z "$PID" ]
    then
        echo Application is already stopped
    else
        echo kill $PID
        kill $PID
    fi
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    配置开机启动

    1. 创建svn.service文件
      [root@server-002 ~]# vim /etc/systemd/system/svn.service
    [Unit]
    Description=svn service
    After=syslog.target
    
    [Service]
    Type=forking
    ExecStart=/usr/bin/svnserve -d -r /home/svn --config-file=/home/svn/conf/svnserve.conf --log-file=/home/svn/logs/svn.log
    User=svn
    Group=svn
    
    [Install]
    WantedBy=multi-user.target
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    1. 激活开机启动svn服务
      [root@server-002 ~]# systemctl daemon-reload
      [root@server-002 ~]# systemctl enable svn

    添加http访问支持

    1. 检查是否已经安装了apache服务
      [root@server-002 ~]# rpm -qa httpd
    2. 如果没有该服务,则安装,否则跳过
      [root@server-002 ~]# yum install httpd -y
    3. 安装mod_dav_svn组件
      [root@server-002 ~]# yum install mod_dav_svn -y
    4. 修改apache启动用户和组为svn
      [root@server-002 ~]# vim /etc/httpd/conf/httpd.conf
    User svn
    Group svn
    • 1
    • 2
    1. 修改subversion.conf配置
      [root@server-002 ~]# vim /etc/httpd/conf.d/subversion.conf
    <Location /svn>
      DAV svn
      SVNListParentPath on
      SVNParentPath /home/svn # 如果想在一个目录下面创建多个版本库的话,则使用SVNParentPath,否则SVNPath。
      AuthType Basic
      AuthName "svn Repo"
      AuthUserFile /home/svn/conf/httpdpasswd
      AuthzSVNAccessFile /home/svn/conf/authz
      Require valid-user
    </Location>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    1. 切换svn用户,创建密码文件并添加用户

      [svn@server-002 ~]$ htpasswd -c -m /home/svn/conf/httpdpasswd admin


    后续添加用户只需执行htpasswd /home/svn/conf/httpdpasswd <username>
    1. 开放80端口

      [root@server-002 ~]# firewall-cmd –add-port=80/tcp –permanent
      [root@server-002 ~]# firewall-cmd –reload

    2. 启动apache

      [root@server-002 ~]# systemctl start httpd
      [root@server-002 ~]# systemctl enable httpd

    添加apache支持后,如果不需要通过svn://192.168.1.2的形式访问,可以不用启动svn,直接启动httpd服务即可。如果二者都要支持,则httpd.service和svn.service都启动,但二者使用的密码文件不相同

  • 相关阅读:
    利用百度轻松语音合成,语音识别
    python圆周率计算小程序(非常慢)
    python成语接龙小游戏
    在数组添加元素时报错:IndexError: list index out of range
    Redis-jedis的使用
    Shiro整合SpringMVC简单实例(一)
    容器
    防重提交功能(Token技术的引入)
    PageUtil
    单例设计模式
  • 原文地址:https://www.cnblogs.com/caicaizi/p/9469882.html
Copyright © 2020-2023  润新知