Configure SVN (Subversion) Server

Note: It may need root user permissions to execute following commands.

(1) Install needed packages

yum install mod_dav_svn subversion

In my PC, packages that were installed are

Note: if you are going to visit SVN repository via http, you shall have apache HTTP server installed firstly.

yum install –y httpd

httpd-2.2.15-30.el6.centos.x86_64 and httpd-tools-2.2.15-30.el6.centos.x86_64 were installed automatically.

(2) Create and configure SVN repository

mkdir /home/svn
cd /home/svn
svnadmin create prjname

After the preceding commands were conducted, your first SVN project with name of prjname would have been created. You need to configure access permissions for the project.

cd /home/svn/prjname/conf
vi svnerve.conf
vi passwd
vi authz

A good sample of these files can be found below.

#FILE svnerve.conf

[general]

anon-access = none

auth-access = write

password-db = /opt/svn/conf/passwd.conf

authz-db = /opt/svn/conf/authz.conf

#FILE passwd

[users]

username = password

#FILE authz

[groups]

admin = username, username1, username2

[prjname:/]

@admin = rw

* =

The conf files let username with password have access to the project. Use the below command to start SVN server.

svnserve –d –r /home/svn

svnserve –d –r /home/svn

Note: if you are going to visit SVN repository via http, you need to configure the http SVN user separately.

vi /etc/httpd/conf.d/subversion.conf

vi /etc/httpd/conf.d/subversion.conf

A good sample of the file can be found below.

LoadModule dav_svn_module     modules/mod_dav_svn.so

LoadModule authz_svn_module   modules/mod_authz_svn.so

# The /svn is according to the repository that you created before.

# The DAV svn shall be just DAV svn no matter the repository name of your SVN server.

<Location /svn>

DAV svn

SVNParentPath /home/svn

AuthType Basic

AuthName "the project name that you want it to be displayed"

AuthUserFile /etc/svn-auth-users

Require valid-user

</Location>

As you can see, the AuthUserFile was specified to be /etc/svn-auth-users. This is because that the http will require a cipher-texted password for the user, which is different from the former …/svn/prjname/conf/passwd file. You can use htpasswd command to
create that file for http login user.

htpasswd -cm /etc/svn-auth-users username

After you input the password for the user, you will find a new file svn-auth-users was created with some cipher text inside.

And to let Apache server have access to the SVN server, you have to do some more configuration.

chown -R apache.apache prjname
## If you have SELinux enabled (you can check it with "sestatus" command) ##
## then change SELinux security context with chcon command ##
chcon -R -t httpd_sys_content_t /home/svn/prjname
## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /home/svn/prjname

At last, please restart the apache server to let the configuration come effect.

Service httpd restart

Go to http://SVN_SERVER_IP:port/svn/prjname/
to visit SVN repository.

(3) Create trunk, branches and tags structure

It’s not necessary to have any of trunk, branches and tags files under the project home, but usually we can find these there files in most famous open source projects. Developers develop and submit under the trunk directory. For some uncertain requirements
or a stage release version, it is better to save them in the branches directory. At last tags is read-only which is used to save phased production version for archiving.  A tree like structure of the project will be similar as below.

- Project_svn_home

+ trunk

++ main.cpp    (latest version which is under developing)

++ common.h

+

+ branches

++ -- r1.0

++ -- + main.cpp (Latest of 1.x version)

++ -- + common.h

++ -- r2.0

++ -- + main.cpp (Latest of 2.x version)

++ -- + common.h

+

+ tags (read-only)

++ -- r1.0

++ -- + main.cpp (version 1.0 release)

++ -- + common.h

++ -- r1.1

++ -- + main.cpp ( version 1.1 release)

++ -- + common.h

++ -- r1.2

++ -- + main.cpp ( version 1.2 release)

++ -- + common.h

...

++ -- r2.0

++ -- + main.cpp ( version 2.0 release)

++ -- + common.h

++ -- r2.1

++ -- + main.cpp ( version 2.1 release)

++ -- + common.h

...

There are two ways to create trunk, branches and tags directory structure.

1) Use the svn mkdir command to either make your directory structure without a working directory.

svn mkdir -m "structure-trunk" svn://localhost/prjname/trunk
svn mkdir -m "structure-trunk" svn://localhost/prjname/branches
svn mkdir -m "structure-trunk"  svn://localhost/prjname/tags

OR

svn mkdir -m "structure-trunk" file:///home/svn/prjname/trunk
svn mkdir -m "structure-trunk" file:///home/svn/prjname/branches
svn mkdir -m "structure-trunk" file:///home/svn/prjname/tags

It may be possible that you have to write some comment to the log file when you are adding these directories without ‘-m‘ option.

2) Or, you can checkout a copy of the repository in into a working directory and do everything from there.

svn co svn://localhost/prjname
cd prjname
svn mkdir trunk tags branches
svn commit -m "Creating basic directory structure"

Notice that you will not see the directories directly inside your repository. However, you can use the svn ls command to see the structure.

svn ls -R svn://localhost/prjname

OR

svn list svn://localhost/prjname

(4) Now you can connect prjname with any type of project in a reachable URI, or you can just check it out and then expand it as your like.

To checkout current developing codes in the trunk directory, you can use the following commands in a shell.

cd /home/user/projects/
svn co svn://localhost/prjname/trunk prjname -username your_user_name

After authentication your user name and password, you will find the project is checkout with the project name that you specified.

However, it’s very possible we want to use some IDE to initialize the project. As with me, I would create a dynamic WEB project by Eclipse and then share it to SVN.

For example, you can create a Dynamic Web Project with the Eclipse.

Then you can right click the home folder of the project and select the Team menu. You can take use the share project function to connect your project with SVN prjname.

svn://svnserver_IP:port/prjname
[Use specified folder name] trunk/

The default SVN port is 3306.

If the hosts of Eclipse and the SVN server are in different private LAN, then port mapping in router can be taken use of to connect the hosts.

I will going to discuss more aspects about SVN such as auto commit in a next article.

Note: It usually can be more comprehensive and helpful to refer to  the subversion manual pagehttp://svnbook.red-bean.com/ if you have questions.

Configure SVN (Subversion) Server

时间: 2024-08-22 14:47:38

Configure SVN (Subversion) Server的相关文章

SVN之Subversion server及TortoiseSVN client简单部署

1.前言 嘿嘿,本文有些内容来自于百度:简单整理并记录一下管理,SVN的一些东西.希望看到此文,能到大家有点帮助. 2.环境介绍 server端操作系统: window 2008 64bit server端软件:Slik-Subversion-1.9.4-x64.msi client端软件:TortoiseSVN-1.9.4.27285-x64-svn-1.9.4.msi 本文最后提供了下载链接. 3.概述     Subversion是一个自由开源的版本控制系统.在Subversion管理下,

CentOS6.X下安装配置独立SVN服务器|Subversion server

Hi 大家好,我是钟义林,今天我们来安装一个Subversion服务吧,Subversion server其实就我们日常说的SVN服务,Subversion(简称SVN,svn),一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS.互联网上很多版本控***务已从CVS转移到Subversion.svn服务器有2种运行方式:独立服务器和借助apache运行.下面我安装独立SVN 首先,清除一下yum的缓存吧,yum clean  all [一]安装

svn(subversion)代码管理

想必大家现在都比较喜欢使用svn(subversion)完成代码管理了,因为它的开源,轻巧,易用.但是这样一个宝贝如果不知道其正确的用法,也会让我们百思不得其解,甚至耽误项目进度,浪费程序员的心血和结晶.   下面就我们在外事项目中使用SVN的经验简单做个说明.   如何正确提交代码?   可能很多人用过微软的VISUAL SOURCESAFE 或者 Team Foundation Server,就认为那还不简单,checkout/checkin 不就完了吗.孰不知由于SVN采用了另一种源代码管

How to configure dns slave server in Linux

A DNS server, or name server, is used to resolve an IP address to a hostname or vice versa.You can set up four different types of DNS servers: A master DNS server for your domain(s), which stores authoritative records for your domain. A slave DNS ser

Configure a syslog server with rsyslog on Ubuntu

A syslog server represents a central log monitoring point on a network, to which all kinds of devices including Linux or Windows servers, routers, switches or any other hosts can send their logs over network. By setting up a syslog server, you can fi

解决You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support问题

错误提示:Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must co

CentOS6.X下安装配置独立SVN服务器Subversion server

Subversion(简称SVN,svn),一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS.互联网上很多版本控***务已从CVS转移到Subversion.svn服务器有2种运行方式:独立服务器和借助apache运行.下面我安装独立SVN 首先,清除一下yum的缓存吧,yum clean all [一]安装 subversion yum install subversion subversion-devel 然后选择y(yes)确认安装,当然

svn报错:This error was generated by a custom hook script on the Subversion server.

rename一下,剪切一份,覆盖一下,提交.

linux下subversion server安装手册

安装基于的Linux版本为:Red Hat Enterprise Linux Server release 6.3. 一 准备需要的安装包. (1)下载 apache: httpd-2.2.23.tar.gz (2) 下载Subverson  .下载地址 http://subversion.tigris.org/downloads/subversion-1.6.12.tar.gz http://subversion.tigris.org/downloads/subversion-deps-1.6