Getting started with SVN and configuring to use

Source: Internet
Author: User
Tags addgroup apache error log subversion client svn svn client svn update vcard tortoisesvn

Getting started with SVN and configuring to use

2009-10-23 Source: Network

SVN, or subversion, is a free and open source version control system that restores data to an earlier version or examines the history of data modifications that can be source code or other types of files.

CVS was the fact standard for open source World version control tools before SVN appeared, but CVS had some inherent flaws, and it took a lot of effort to fix them, so SVN's initiator, Brian, Behlendorf and CollabNet decided to rewrite a version control system to retain the basic idea of CVS, but to fix errors and unreasonable features. As a result, SVN emerged as a successor to CVS. The SVN designers are trying to win the favor of CVS users by making two efforts: keep the design of open source systems and interface styles as similar as CVS, while trying to make up for many of the significant flaws in CVS. As a result of these efforts, migration from CVS to SVN does not require significant change, so more and more people opt for SVN.
Http://svnbook.red-bean.com
http://www.subversion.org.cn

Directory

First, the use of the client
1.1 Linux System general use (Ubuntu)
1.2 General use under Windows systems
1.3 Linux uses SVN+SSH authentication (no relevant information is found @_@)
1.4 Use SVN+SSH authentication under Windows
Second, server-side configuration
Svnserve Configuration under 2.1 Linux
2.2 Svnserve configuration under Windows
SVNSERVE+SSH configuration under 2.3 Linux
2.4 Svnserve+ssh Configuration under Windows (use Cygwin, abbreviated)
Apache-based SVN server configuration under 2.5 Linux
2.6 The Apache-based SVN server configuration under Windows
Third, the establishment of version library
3.1 Linux to create a version library
3.2 Create a version library under Windows

Most people start using SVN from the client, and here's how to use the client first. Suppose you have already assumed that the SVN server, whose folder address is Http://domain/svn/trunk/myproject, is named Test and the password is test. (If the server-side configuration is SVN, use the URL at the beginning of svn://; if the server-side is configured with SVN+SSH, use the URL at the beginning of svn+ssh to access)

first, the use of the client

general use under 1.1 Linux (Ubuntu) Systems

1 first need to install SVN client, Ubuntu under the use of $sudo Apt-get install subversion (other please baigoogledu, Yu Tong)

2 checkeout command: Use the checkout command for the first time, copy the server directory to the local current directory, and create a hidden folder record version information:
[Working directory] $svn Checkout "Http://domain/svn/trunk/myproject"--username test
and enter the password.

3 SVN update command: Get the latest version on the server
[Working directory] $SVN update (except for the first time URL and username and password, the system will remember)

4 SVN Add command: To add a non-version-controlled local file to version control:
[Working directory] $SVN add hello.c

5 svn commit: Upload the local file to the server

[Working directory] $SVN commit (if you have a new file, first SVN add)

1.2 general use under Windows systems

1) Installation client: Http://tortoisesvn.net/downloads

2 Create a new folder (working directory), right-click Select Checkout, fill in URL and username password

3) Working Directory right key update

4) Working Directory right key add

5) Working Directory right key commit

1.3 Linux uses SVN+SSH authentication (no relevant information is found @_@)

1.4 Use SVN+SSH authentication under Windows

(Refer to Ubuntu set up SVN server and build Svn+ssh client in Windows)

1.4.0 installation TortoiseSVN, Puttygen, pageant
Http://sourceforge.net/projects/tortoisesvn
http://www.chiark.greenend.org.uk/~sgtatham/putty/

1.4.1 Convert private key format
1 Copy the file <username>key under Linux to Windows, run Puttygen;
2 Select Menu Conversions->import key; Select File <username>key, prompt "Enter passphrase for key", enter the Passphrase keyword used to create public key pair;
3 Select Parameters as "SSH-2 DSA" or "SSH-2 RSA"->save private key-> Save file name as USERNAME>KEY.PPK.

1.4.2 establishes the association of TORTOISESVN with pageant and joins the private key pageant:
1 right mouse button Select Tortoisesvn->settings->network->ssh Client, Input:
C:/Program Files/tortoisesvn/bin/tortoiseplink.exe
2 right mouse button select Tortoisesvn->repobrowser input URL:
Svn+ssh://<username>@<svnserviceip>/usr/local/svn/trunk
3 Run pageant, right click on the bottom right corner of the screen icon-〉add key, the private key file <USERNAME>KEY.PPK join.
--If you do not want to cache the SSH password, then 8th, 9 steps do not need to keep only the second step, but each check out and check in into a folder to enter a two times password, annoying you:

second, server-side configuration

Web server deployment can have three choices, configured from simple to complex columns

Svnserve

Svnserve over SSH

· APACHE+MOD_DAV_SVN Module

The following from the simplest start, introduce svnserve.

Update Server-side configurations under Windows can be installed using VISUALSVN Server for Dummies.

Official website: http://www.visualsvn.com/

Reference Link: VISUALSVN Series introduction (with detailed installation process introduction, here will not be reproduced)

2.1&2.2 Configuration Svnserve

Svnserve is a lightweight server that communicates with the client via a custom stateful protocol based on TCP/IP, and the client accesses a Svnserve server by using a URL that starts with a svn://or svn+ssh://svnserve.

svnserve configuration under 2.1 Linux

2.1.0 Similarly, using commands $sudo apt-get install subversion

2.1.1 Svnserve as a standalone daemon, listening for requests
$svnserve-D
$ #svnserve is now running, listening on port 3690
--You can use the--listen-port=[port number to specify the port, or--listen-host=[host name, to specify the host name
Assuming that a version library has been established in the/usr/local/repositories/project path (mentioned later in the build library), the client can use the svn://[host]/usr/local/repositories/ Project for Access
--You can use the-r option to limit the output to only the version library under the specified path, making client access simpler:
$svnserve-D-r/usr/local/repositories
The client can access the]/project as long as it uses the svn://[host

2.1.2 through inetd use Svnserve
$svnserve-I.
-At this point Svnserve will attempt to use a custom protocol to call the Subversion client through stdin and stdout, with the default port of 3690. You can add the following lines to/etc/services:
SVN 3690/tcp #subversion
SVN 3690/udp #subversion
-If you are using the classic Unix-like inetd daemon, you can add the following lines to/etc/inetd.conf if a client connects to the port 3690,inetd generates a svnserve process to do the service
SVN stream TCP nowait svnowner/usr/bin/svnserve svnserve-i

2.1.3 Set Svnserve Built-in certification

To edit the conf/svnserve.conf file for the version Library directory:
1) Set up anonymous access
[General]
Anon-access = None #无权限
Anon-access = Read #只读
anon-access = Write #打开匿名的写访问, but it is dangerous to control who can modify the version library
2 Use User and password
2.1 Define the file and an authentication domain that holds the username and password
[General]
Password-db = <userfile> #指出保存用户和密码列表的文件, can be an absolute or relative path
Realm = Example Realm #定义认证域
Anon-access = Read
auth-access = Write
2.2) then specify the username and password in the UserFile file: (format "username = password")
[Users]
Harry = Foopassword
Sall = Barpassword

2.2 svnserve configuration under Windows

2.2.0 Installation Svnserve

1 to get the latest version of subversion from http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91
(If the Subversion,svnserve is already running on the server before, you need to stop the service first)

2 Install subversion, then go to Subversion's installation directory, find files in Bin directory svnserve.exe,int13_ Svn.dll,libapr.dll,libapriconv.dll,libapriutil.dll,libdb*.dll,libeay32.dll and Ssleay32.dll, copy them to the server directory (such as c:/ Svnserve).

2.2.1 To run Svnserve in a Guardian way

When you enter Svnserve.exe--daemon in the Command Line window, Svnserve will wait for the request in Port 3690, and the--daemon option tells Svnserve to run as a daemon so that it does not exit until the manual termination. The inconvenience of this approach is the need to keep the command line window closed.

2.2.2 Svnserve as a Windows service

Svnserve, as a Windows service, runs in the background, can be performed automatically at startup, and can start and stop services using a consistent management interface with other Windows services.
You need to define a new service (create Svnserve) using the command-line tool Sc.exe to indicate the invocation of Svnserve when Windows starts:
C:/>SC Create Svnserve
Binpath= "/" c:/svnserve/svnserve.exe/"--service--root c:/repos"
Displayname= "Subversion"
depend= TCPIP
start= Auto
-note that the entire BinPath value is placed in double quotes in order to avoid characters such as spaces in the directory name, and the SC command line is special. In key= value pairs, there must be no spaces between the key and the =, but before value, a space is required.

Once a service is defined, it can be stopped, started, and queried using a GUI tool, such as the service Management panel, or through the command line:
C:/>net Stop SVN
C:/>net Start SVN
C:/>SC Delete svn (need to be sure to stop the service first)

2.2.3 Set Svnserve Built-in certification

Ditto Linux configuration file.

2.3&2.4 Configuration Svnserve+ssh

SVNSERVE+SSH configuration under 2.3 Linux

2.3.0 Introduction and Installation SSH
In this way, Svnserve does not start as a daemon, but SSH to start the Svnserve, which is authorized by SSH users.
$sudo apt-get Install SSH

2.3.1 Create an account
$sudo AddUser <username> #为参与项目开发的成员建立用户帐户
$sudo addgroup <groupname> #建立用户组
$sudo addgroup <username> <groupname> #将用户帐户添加进用户组

2.3.2 generate key pairs for members
You must first switch to <username> user login Linux:
$sudo <username>
$ (Prompt to enter password)
$CD ~/
$whoami
<username> $ssh-kegen-b 1024-t dsa-n <passphrase>-F <filename> #使用DSA加密 can also be converted to RSA encryption
--This produces two files: the private key <username>key and the public key <username>key.pub
Then create the directory/home/<username>/.ssh and copy the public key to the directory:
$CP <username>key.pub/home/<username>/.ssh/authrized_keys #文件名必须为authorized_keys

2.4 svnserve+ssh configuration under Windows

You need to use Cygwin to configure SSH, and here's a little more information for reference http://tortoisesvn.net/node/156

2.5&2.6 SVN configuration based on Apache server

Overview

Apache HTTP Server is a subversion available "heavy" network server, through a custom module, httpd can let the SVN version of the library through the WEBDAV/DELTAV protocol before the client visibility. You can point the browser to the URL of the version library and browse the content without having to install an SVN client.

The Apache-based SVN requires four parts of two packages: the Apache httpd2.0 and the Mod_dav DAV module contained in it, subversion and the MOD_DAV_SVN modules that are released with it. After you have the above components, the configuration steps are generally as follows
1) Configure http2.0 and use Mod_dav to start
2) Install MOD_DAV_SVN plugin for Mod_dav
3) Configure httpd.conf to release the version library

Apache-based SVN server configuration under 2.5 Linux

(Refer to http://www.123shang.cn/blog/?p=53)

(Refer to "Ubuntu under Svn+apache version Management Server Configuration")

2.5.1 Installation Aphache
$sudo apt-get Install apache2 #安装apache
$sudo apt-get Install LIBAPACHE2-SVN #安装相关组件
$sudo Apt-get Install Subversion #安装svn
Start Apache after installation
$/usr/local/apache/bin/apachectl–k start
--Using the browser to view http://localhost/, get it works, indicating that Apache has been configured successfully.

2.5.2 Create a version library (see sect. III)

2.5.3 add user and set password file

The password file for the

version library, generally named Passwdfile, is created by the user by command, which holds the user name of the authorized user and the password MD5 encrypted. Create the password file, the password file is saved in the version library file directory, in the terminal through the following command to create a password file:
$htpasswd-C/etc/svn/passwordfile username 
Passwordfile Password file name, can be named by the user  
username you want to add the user name, such as zhangsan,lisi,wangwu 
-C to create a password file
Press the prompt to enter a password, add success will prompt add U Ser username, and then you can continue adding a second user. &NBSP
$htpasswd/etc/svn/passwordfile seconduser

2.5.4 httpd.conf File Modification
conf file normal installation in the etc/apache2/directory, double-click to open for editing, add the following:
LoadModule dav_svn_module modules/mod_dav_svn.so Load MOD_DAV_SVN module
LoadModule authz_svn_module/usr/lib/apache2/modules/mod_authz_svn.so loading MOD_ANTHZ.SVN module
<Location/vcard>
DAV SVN
Svnpath/home/bb/svn/vcard/indicates the path to the version library
AuthType Basic Authentication type is basically authentication
AuthName "SVN repos" certification name, will be in the IE interface pop-up a dialog box, the title is SVN repos
Authuserfile/home/bb/svn/vcard/vcardpasswdfile load password file, Access version Library user's file, use Apache htpasswd command to generate
# Authzsvnacessfile//home/bb/svn//vcard/accesspolicy access to version library permissions files
# satisfy any
Require Valid-user requires authentication of the user, that is, it cannot be accessed anonymously; If this statement is not available, only the first user can access the new library
</Location>
Save file exit, restart Apache
#/usr/local/apache/bin/apachectl–k Restart
Test:
$SVN Checkout HTTP://LOCALHOST/SVN

2.6 The Apache-based SVN server configuration under Windows

2.6.1 Download Install Apache
apache:http://httpd.apache.org/download.cgi
-If you install Apache as a service, it will run with the local system account. It would be safer to create a separate user for Apache to run it.
--Make sure that the user running Apache has full access to the version library (right-key version Library directory-> Property-> security). Otherwise, users will not be able to submit their changes.
--even if Apache is running on native system, you have to set it up to read and write to the version library directory completely.
If this license is not configured for Apache, the user will get an "No access" error message, which is shown as Error 500 in the Apache error log.

2.6.2 Configuration Subversion

Using the WINDWOS resource Manager, come to the installation directory of Subversion (usually C:/Program files/subversion), locate files httpd/mod_dav_svn.so and Mod_authz_ svn.so, copy these files to the Apache module directory (usually C:/Program File/apache group/apache2/modules).

The

2.6.3 Configuration httpd.conf file
path is typically C:/Program Files/apache group/apache2/conf/httd.conf), modifying the following:
Remove the comment number "#" for the following two lines:  
#LoadModule dav_fs_module modules/mod_dav_fs.so 
#LoadModule dav_module modules/mod_dav.so
At the end of the LoadModule section, add the following two lines:
LoadModule dav_svn_module modules/mod_dav_svn.so 
LoadModule Authz_svn_module Modules/mod_authz_svn.so
Add the following line at the end of the file so that Apache knows which URL will be used by subversion:
<location/svn>
DAV svn
Svnpa RentPath d:/svn 
AuthType basic 
AuthName "Subversion repositories" &NBSP;
AuthUserFile D:/pass WD&NBSP
#AuthzSVNAccessFile d:/svnaccessfile 
Require valid-user 
</location>
--match "All your version libraries will be in the D:/SVN directory, and access to your version library can be done using such url:http://myserver/svn/, which will be limited by the username/password in the passwd file," says the.
to create a passwd file, you can open the command line, switch the current directory to the Apache2 directory, and enter the command:  
C:/Program files/apache group/apache2 >bin/htpasswd-c passwd <username>
Restart the Apache service. The
uses browser tests.

third, the establishment of version library

On the previous server configuration we usually assume that the version library has been built, in order to avoid repeating the operation in each configuration, so separate it out.

After the version library is created, several files and folders are generated in the directory:
The DAV directory is a directory that is provided to Apache and MOD_DAV_SVN to store internal data;
The DB directory is all version-controlled data files; The directory where the Hooks directory places the hook script file;
Locks is used to place a directory of Subversion repository locking data to track clients accessing the repository;
The format file is a text file that contains only an integer that represents the version number of the current file library configuration.

3.1 Linux to create a version library
There are two types of data storage formats for a version library: Berkeley DB and Fsfs, and FSFS format is recommended, and you can see the difference between references.
When you create a version library, you run the following command at the terminal:
# runs the command to create a version library, specifies that the data is stored as FSFS, and if you want to specify Berkeley DB, replace Fsfs with BDB
$ svnadmin Create--fs-type Fsfs/etc/svn/repos creates a version library, after running this command, we can see the files that a version library should have
To change the access rights of a version library
$ sudo mkdir/home/svn
$ cd/home/svn
$ sudo mkdir myproject
The previous three commands are used to create a version library directory, which can be omitted if it is established; The following three are used to modify permissions
$ sudo chown-r www-data myproject
$ sudo chgrp-r subversion MyProject
$ sudo chmod-r g+rws myproject This command allows the user to read and write to the version library, which can be updated to submit

3.2 Create a version library under Windows

You can use the TortoiseSVN graphical completion of this step, in the directory E:subversionrepository "right button->tortoisesvn->create Repository here ...", You can then select the version library mode, use the default, and then create a series of directories and files.
[Tips] If the download is a Setup.exe version, Setup will automatically set the system variables, if the download is a zip version of the need to manually set system variables.
You can also use the command line to create:
C:/> Svnadmin Create f:/svn/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.