Ubuntu12.04.2安装和配置SVN
第一步:安装apache2、libapache2-svn、subversion
sudo apt-get install apache2
sudo apt-get install subversion
sudo apt-get install libapache2-svn
// 重启apache2
sudo service apache2 restart
第二步:创建SVN库和项目
sudo mkdir /home/svn // 创建SVN库
sudo svnadmin create /home/svn/myproject //创建项目
第三步:创建组并添加成员
sudo addgroup subversion //创建一个叫subversion的组为拥有仓库所在的目录
sudo usermod -G subversion -a www-data //将自己和“www-data”(Apache用户)加入组成员中
cat /etc/group | grep subversion //查看是否设置成功
//系统提示:subversion:x:1001:www-data
第三步:修改项目权限
sudo chown -R root:subversion /home/svn/myproject
sudo chmod -R g+rws /home/svn/ myproject
//赋予组成员对所有新加入文件仓库的文件拥有相应的权限
//查看txn-current-lock文件的权限和用户以及组信息
ls-l /home/svn/myproject/db/txn-current-lock
//系统提示:-rw-rwSr--1 root subversion 0 2011-01-25 17:47/home/svn/myproject/db/txn-current-lock
第四步:通过命令访问库
sudo svn co file://lodalhost/home/svn/myproject //第一种方法,知道主机名时用
sudo svn co file:///home/svn/myproject //第二种方法,当不确定主机名时用,这用的是file:///,三个斜杠
系统提示:取出版本0。
己可以取出版本,说明SVN服务器己正常运行,下面试从webdav访问
第五步:配置apache2
修改/etc/apache2/mods-available/dav_svn.conf
sudo vi /etc/apache2/mods-available/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 ashttp://hostname/svn/
#Note, a literal /svn should NOT exist in your document root.
<Location /svn>
#Uncomment this to enable the repository
DAVsvn
#Set this to the path to your repository
#SVNPath/var/lib/svn
#Alternatively, use SVNParentPath if you have multiple repositoriesunder
#under a single directory (/var/lib/svn/repo1, /var/lib/svn/repo2,...).
#You need either SVNPath and SVNParentPath, but not both.
SVNParentPath/home/svn
#Access control is done at 3 levels: (1) Apache authentication, via
#any of several methods. A "Basic Auth" section iscommented out
#below. (2) Apache <Limit> and <LimitExcept>, alsocommented out
#below. (3) mod_authz_svn is a svn-specific authorization module
#which offers fine-grained read/write access control for paths
#within a repository. (The first two layers are coarse-grained; you
#can only enable/disable access to an entire repository.) Note that
#mod_authz_svn is noticeably slower than the other two layers, so if
#you don't need the fine-grained control, don't configure it.
#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').
AuthTypeBasic
AuthName"Subversion Repository"
AuthUserFile/etc/subversion/dav_svn.passwd
#To enable authorization via mod_authz_svn (enable that moduleseparately):
#<IfModulemod_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').
<LimitExceptGET PROPFIND OPTIONS REPORT>
Requirevalid-user
</LimitExcept>
</Location>
文件内容到此结束=================================
//加入代码后重启apache2
sudo /etc/init.d/apache2 restart
第六步:添加SVN用户
//建立/etc/subversion/passwd文件,这个文件里包含了用户授权的详细信息
//第一次添加用户使用参数“-c”以后再添加就不用了
sudo htpasswd -c /etc/subversion/passwd [user_name]
//访问文件仓库
svn co http://localhost/svn/myproject myproject --username [username]
取出版本 0。
//OK!通过web页面访问到版本库了
第七步:创建项目布局,测试提交
svn mkdir "http://localhost/svn/myproject/branches" -m "create the project breanches folder" --username 【username】 --password 【password】
svn mkdir "http://localhost/svn/myproject/tags" -m "create the project tags folder" --username 【username】 --password 【password】
svn mkdir "http://localhost/svn/myproject/trunk" -m "create the project trunk folder" --username 【username】 --password 【password】
也可以写成一句
svn mkdir "http://localhost/svn/myproject/trunk" "http://localhost/svn/myproject/branches" "http://localhost/svn/myproject/tags" -m "create the project layout folders" --username 【username】 --password 【password】
问题收集
1svn: xxx/ is already a working copy for a different url解决办法
中文错误提示:svn:“xxx”已经是指向不同URL的工作副本
现象重现 :
sudo svn co file://lodalhost/home/svn/myproject
//成功
svn co http://localhost/svn/myproject myproject --username [username]
//提示错误
原因分析:
首先说明下原因:
出现这种情况大多是由于原有的目录是使用svn更新的,并且指定了一个更新的url,比如说http://192.168.10.1/svn/xxx,如果此url由于某种原因无法使用,而换成了http://192.168.10.2/svn/xxx,那么要实现从第二个url取出文件,仅仅将用于更新的shell脚本中的url替换成最新的是不够的,马上就会出现标题中的提示
解决方法:
1.保留工程目录,将此目录下的所有文件清空(主要是原有的svn文件的干扰)
2.重新checkout