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.[-]* *.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

阿里云ubuntu 创建svn服务器的更多相关文章

  1. 阿里云ubuntu搭建SVN服务器

    系统:Ubuntu 14.04 64位 新手注意:连接到服务器之后,默认会在用户文件夹位置“~”,使用cd /命令可以回到根目录.SVN搭在公共的位置比较稳妥. 1.通过apt-get安装subver ...

  2. 阿里云(centos)下svn 服务器搭建

    安装说明 系统环境:阿里云centos安装方式:yum install subversion 检查已安装版本 #检查是否安装了低版本的SVN[root@localhost /]# rpm -qa su ...

  3. 在阿里云Ubuntu 14.04 Linux服务器上安装docker

    参考 How To Install and Use Docker: Getting Started 这篇最靠谱的文档在阿里云 Ubuntu  14.04 服务器上成功安装 docker . ---- ...

  4. 本地Windows远程桌面连接阿里云Ubuntu服务器

    本地Windows远程桌面连接阿里云Ubuntu 16.04服务器: 1.目的:希望通过本地的Windows远程桌面连接到阿里云的Ubuntu服务器,通过远程桌面图形界面的方式操作服务器. 2.条件: ...

  5. ubuntu搭建svn服务器并htpp访问版本库并svn与web同步

    Ubuntu搭建SVN服务器多版本库 1  介绍   Subversion是一个自由,开源的版本控制系统,这个版本库就像一个普通的文件服务器,不同的是,它可以记录每一次文件和目录的修改情况.这样就可 ...

  6. ubuntu搭建svn服务器(转)

    在阿里云买了个服务器,想上传东西,samba不好用,想起来可以搭个svn用,找到了这篇. 1. 安装SVN apt-get install subversion 2. 建立svn仓库 1). 建立sv ...

  7. 阿里云Ubuntu快速建站

    阿里云Ubuntu快速建站 有一个小笑话: 从前有个程序员遇到了一个问题.他想,没事,我懂,用线程就好了.现他有两个问题了. 本人小白,对网站部署什么都不懂,只是申请个阿里云服务器,把我的站点放上去. ...

  8. 阿里云ECS搭建SVN配置外网

    阿里云ECS搭建SVN后,配置外网启动不了,检查云服务器没发现问题,后来发现是阿里云拦截,需要在阿里云控制台ECS安全组新增如下配置:

  9. 【站长起步】阿里云+Ubuntu+java 7+ Tomcat 7 +Nginx1.6 +Mysql 5.6

    本文记载了在阿里云ubuntu+java 镜像环境下搭建站点server环境中遇到的的错误和解决方式. 作为一个年轻人,是肯定不会去用alidata这个现成的环境的.怎么办? 所有删除.立刻创建一个 ...

随机推荐

  1. Pandas缺失数据

    数据丢失(缺失)在现实生活中总是一个问题. 机器学习和数据挖掘等领域由于数据缺失导致的数据质量差,在模型预测的准确性上面临着严重的问题. 在这些领域,缺失值处理是使模型更加准确和有效的重点. 何时以及 ...

  2. Pandas注意事项&窍门

    警告和疑难意味着一个看不见的问题.在使用Pandas过程中,需要特别注意的地方. 与Pandas一起使用If/Truth语句 当尝试将某些东西转换成布尔值时,Pandas遵循了一个错误的惯例. 这种情 ...

  3. Linux平台上DPDK入门指南

    1. 简介 本文档包含DPDK软件安装和配置的相关说明.旨在帮助用户快速启动和运行软件.文档主要描述了在Linux环境下编译和 运行DPDK应用程序,但是文档并不深入DPDK的具体实现细节. 1.1. ...

  4. Hyper:基于Hypervisor的容器化解决方案

    近日,初创公司HyperHQ发布了他们的开源项目Hyper,Hyper是一个可以在hypervisor上运行Docker镜像的引擎,它融合了Docker容器和虚拟机的优点,旨在打造一个性能更好.更安全 ...

  5. Codeforces Round #299 (Div. 2)D. Tavas and Malekas

    KMP,先预处理按每个节点标记,扫一遍更新每个匹配位置,最后kmp判断是否有重合而且不相同的地方 注意处理细节,很容易runtime error #include<map> #includ ...

  6. XML转Map

    public static Map<String, String> xmlToMap(HttpServletRequest request) throws IOException, Doc ...

  7. 如何批量更改linux文件的内容

    在工作当中,我们往往需要修改某个文件夹下面所有文件的内容,例如把里面的日期统一替换成新的日期,或者把某一串字符替换成另外一串字符,这时我们就可以使用sed命令: sed -i "s/olds ...

  8. 【spark】RDD操作

    RDD操作分为转换操作和行动操作. 对于RDD而言,每一次的转化操作都会产生不同的RDD,供一个操作使用. 我们每次转换得到的RDD是惰性求值的 也就是说,整个转换过程并不是会真正的去计算,而是只记录 ...

  9. LeetCode OJ:Search for a Range(区间查找)

    Given a sorted array of integers, find the starting and ending position of a given target value. You ...

  10. L137

    Uncontacted Tribes at Risk Amid ‘Worrying' Surge in Amazon Deforestation Illegal loggers and militia ...