• 阿里云ubuntu 创建svn服务器


    1.SubVersion服务安装

    sudo apt-get install subversion
    sudo apt-get install libapache2-svn

    2.服务器配置

    2.1相关用户、组的设定
    将自己和“www-data”(Apache 用户)加入组subversion中

    sudo addgroup subversion
    sudo usermod -G subversion -a www-data

    看下结果:

    cat /etc/group|grep subversion

    这里注意,需要注销然后再登录以便您能够成为 subversion 组的一员,然后就可以执行签入文件(Check in,也称提交文件)的操作了
    仓库位置我们就放在/home/svn下吧(注意,在阿里云里数据最好放在数据盘里,不要放在系统盘,系统盘太小):

    sudo mkdir /home/svn

    2.2配置subversion
    编辑/etc/subversion/config 文件,修改相关设置(笔者基本上是默认设置,没做任何修改)

    ### Section for configuring miscelleneous Subversion options.
    [miscellany]
    global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store
    ### Set mime-types-file to a MIME type registry file, used to
    ### provide hints to Subversion's MIME type auto-detection
    ### algorithm.
    # mime-types-file = /path/to/mime.types
    
    ### Set enable-auto-props to 'yes' to enable automatic properties
    ### for 'svn add' and 'svn import', it defaults to 'no'.
    ### Automatic properties are defined in the section 'auto-props'.
    enable-auto-props = yes
    
    
    ### Section for configuring automatic properties.
    [auto-props]
    ### The format of the entries is:
    ### file-name-pattern = propname[=value][;propname[=value]...]
    ### The file-name-pattern can contain wildcards (such as '*' and
    ### '?'). All entries which match (case-insensitively) will be
    ### applied to the file. Note that auto-props functionality
    ### must be enabled, which is typically done by setting the
    ### 'enable-auto-props' option.
    *.c = svn:eol-style=native
    *.cpp = svn:eol-style=native
    *.h = svn:eol-style=native
    *.dsp = svn:eol-style=CRLF
    *.dsw = svn:eol-style=CRLF
    *.sh = svn:eol-style=native;svn:executable
    *.txt = svn:eol-style=native
    *.png = svn:mime-type=image/png
    *.jpg = svn:mime-type=image/jpeg
    Makefile = svn:eol-style=native
    *.php = svn:keywords=Id Rev Date URL Revision Author

    global-ignores是提交时忽略的文件类型,启用auto-props后,让subversion自动添加Id,Revision等keywords
    这样就可以使用svn的keywords了。特别是eclipse里就方便多了。设置一下就可以使用
    $$Id$$、$$Reversion $$、$$Date $$、$$Author$$ 、$$URL$$作为注释模板的内容,方便极了。
    如果在客户端访问subversion版本库时出现这个错误:
    svnserve.conf:102: Option expected
    为什么会出现这个错误呢,就是因为subversion读取配置文件svnserve.conf时,无法识别有前置空格的配置文件。
    要避免出现这个错误,应该在去掉这些行前的#时,也要顺手去掉前面的空格。

    3.apache mod_dav_svn 配置
    通过 WebDAV 协议访问(http://)
    关于WebDAV :
    WebDAV (Web-based Distributed Authoring and Versioning) 一种基于 HTTP 1.1协议的通信协议.它扩展了HTTP 1.1,在GET、POST、HEAD等几个HTTP标准方法以外添加了一些新的方法,使应用程序可直接对Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还可以支持文件的版本控制。
    编辑 /etc/apache2/mods-available/dav_svn.conf :

    root@hywd:/etc/apache2/mods-available# cat dav_svn.conf
    # dav_svn.conf - Example Subversion/Apache configuration
    #
    # For details and further options see the Apache user manual and
    # the Subversion book.
    #
    # NOTE: for a setup with multiple vhosts, you will want to do this
    # configuration in /etc/apache2/sites-available/*, not here.

    # <Location URL> ... </Location>
    # URL controls how the repository appears to the outside world.
    # In this example clients access the repository as http://hostname/svn/
    # Note, a literal /svn should NOT exist in your document root.
    <Location /svn>
    #enable the repository
    DAV svn

    # Set this to the path to your repository
    #SVNPath /home/svn/vod
    # Alternatively, use SVNParentPath if you have multiple repositories under
    # under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2, ...).
    # You need either SVNPath and SVNParentPath, but not both.
    #用这个,以便放多个repository
    SVNParentPath /home/svn

    # Basic Authentication is repository-wide. It is not secure unless
    # you are using https. See the 'htpasswd' command to create and
    # manage the password file - and the documentation for the
    # 'auth_basic' and 'authn_file' modules, which you will need for this
    # (enable them with 'a2enmod').
    AuthType Basic
    AuthName "Subversion Repository"
    #指定基本用户验证的密码文件存放位置
    AuthUserFile /etc/subversion/dav_svn.passwd

    # To enable authorization via mod_authz_svn
    #mod_authz_svn配置文件的位置, 有

     <IfModule mod_authz_svn.c>

    AuthzSVNAccessFile /etc/subversion/dav_svn.authz

     </IfModule>

    # The following three lines allow anonymous read, but make
    # committers authenticate themselves. It requires the 'authz_user'
    # module (enable it with 'a2enmod').
    #<LimitExcept GET PROPFIND OPTIONS REPORT>
    Require valid-user
    #</LimitExcept>

    </Location>

    重启 Apache 2 Web 服务器

    sudo /etc/init.d/apache2 restart

    4.创建 SVN 文件仓库

    cd /home/svn
    sudo mkdir myproject

    #更改版本库所属用户、组

    sudo chown -R root:subversion myproject
    sudo svnadmin create /home/svn/myproject

    #赋予组成员对所有新加入文件仓库的文件拥有相应的权限:

    sudo chmod -R g+rws myproject

    5.密码文件dav_svn.passwd的创建

    sudo htpasswd -c /etc/subversion/dav_svn.passwd user_name


    它会提示你输入密码,当您输入了密码,该用户就建立了。“-c”选项表示创建新的/etc/subversion/dav_svn.passwd 文件,所以user_name所指的用户将是文件中唯一的用户。如果要添加其他用户,则去掉“-c”选项即可:

    sudo htpasswd /etc/subversion/dav_svn.passwd other_user_name

    6.授权配置文件dav_svn.authz (该文件如果没有,就自己创建)
    这里我指定了两个组:管理员组和测试组,指定了两个仓库(vod 、 ThinkPHP 和ftpuserms)的权限 。
    vod仓库下管理员组设置为读写权限,测试组只有读的权限
    ThinkPHP仓库下管理员组设置为读写权限,测试组只有读的权限
    定义ftpuserms储存库下test目录的访问权限:
    禁止所有用户访问,星号代表所有用户,权限为空代表没有任何权限
    打开test3用户的读权限,打开administrator组的读写权限

    [groups]
    administrator=admin,yuan
    tester=test1,test2,test3
    
    [vod:/]
    @administrator=rw
    tester=r
    
    [ThinkPHP:/]
    @administrator=rw
    tester=r
    
    [ftpuserms:/test]
    @administrator=rw
    *=
    test3=r

    启动SVN服务器:

    killall svnserve; 
    svnserve -d -r /home/svn/

    您可以通过下面的命令来访问文件仓库:

    svn co http://hostname/svn/myproject myproject --username user_name --password passwd

    如果在Check in的时候遇到如下错误:
    Can’t open ‘/home/svn/myproject/db/txn-current-lock’: Permission denied
    查看txn-current-lock文件的权限和用户以及组信息,应该类似于:
    ls -l /home/svn/myproject/db/txn-current-lock
    -rw-rwSr– 1 root subversion 0 2009-06-18 15:33 txn-current-lock

    除了权限以外,用户及其组如果不对,则仍然会遇到上述问题,可以再次运行命令:

    sudo chown -R root:subversion myproject

    参考文章:
    http://ihacklog.com/post/ubuntu-svn-setup.html

  • 相关阅读:
    【Java异常】idea 报错:无效的目标发行版:17 的解决办法
    springboot实现MyBatis分页
    已解决No converter for XXX with preset ContentType ‘application/vnd.msexcel;charset=utf8‘
    mybatis if标签判断boolean等于true或者flase
    Java实现Excel导入和导出
    文件上传报错:Current request is not a multipart request的解决办法
    二维数组内的元素获取交集
    .Net Core MemoryCache 缓存
    SQL Server调用OLE对象
    SQL Server中使用正则表达式
  • 原文地址:https://www.cnblogs.com/likwo/p/3152365.html
Copyright © 2020-2023  润新知