Install 1. check whether cvsrpm-qa | grepsubversion2. install yuminstallsubversion3. test whether the installation is successful/usr/bin/svnserve -- version. if the following message is displayed, the installation is successful...
- Install
1. check whether cvs is installed.
Rpm-qa | grep subversion
2. Installation
Yum install subversion
3. test whether the installation is successful.
/Usr/bin/svnserve -- version
If the following message is displayed, the installation is successful.
--------------------------------------
Svnserve, Version 1.6.11 (r934serve)
Compiled on Apr 11, maid: 28: 04
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/site.
This product contains software developed by CollabNet (http://www.Collab.Net.
The backend (FS) module of the library is available in the following versions:
* Fs_base: The module can only operate BDB version libraries.
* Fs_fs: This module works with the text file (FSFS) version Library.
Cyrus SASL authentication is available.
--------------------------------------------------------------
II. configuration
1. create a directory: repos can be used to store all SVN files.
Mkdir-p/opt/svndata/repos
Note: The Directory (project name) path here can be changed in the following format:
Mkdir-p directory path (for example, mkdir-p/www/svn/project)
2. create a version repository (use svnadmin create directory repository path to be consistent with the directory created above)
Svnadmin create/opt/svndata/repos
3. modify the configuration file of the svn repository.
Vi/opt/svndata/repos/conf/svnserve. conf
Modify the format as follows. The value of realm is the project name, which is repos in this example.
[General]
Anon-access = none
Auth-access = write
Password-db =/opt/svndata/project/conf/passwd
Authz-db =/opt/svndata/project/conf/authz
Realm = repos
Note: modifications to user configuration files take effect immediately without the need to restart svn.
4. add a user
Vi/opt/svndata/repos/conf/passwd
To add SVN users, you only need to add an entry in the format of "username = password" to the/opt/svn/project/conf/passwd file.
For testing, I added the following content:
[Users]
# Harry = harryssecret
# Sally = sallyssecret
Pm = pm_pw
Server_group = server_pw
Client_group = client_pw
Test_group = test_pw
5. modify the user access policy
Vi/opt/svndata/repos/conf/authz
Record the user's access policy. The following is a reference:
[Groups]
Project_p = pm
Project_s = server_group
Project_c = client_group
Project_t = test_group
[Project:/]
@ Project_p = rw
* =
[Project:/server]
@ Project_p = rw
@ Project_s = rw
* =
[Project:/client]
@ Project_p = rw
@ Project_c = rw
* =
[Project:/doc]
@ Project_p = rw
@ Project_s = rw
@ Project_c = rw
@ Project_t = rw
* =
The above information indicates that only pm has the read and write permission for the root directory, server_group can access the server directory, client_group can access the client directory, and everyone can access the doc directory.
Of course, the above is a complicated permission control. if it is just a test, it can be simpler. Create a user group and place all users to one user group, as shown below:
[Groups]
Admin = pm, server_group, client_group, test_group
[/]
@ Admin = rw
This article does not detail permission control. you can consult du Niang.
5. start the svn service
Svnserve-d -- listen-port 3690-r/opt/svndata/repos (run as root user)
If multiple projects are under development at the same time, you can enable multiple SVN services through different ports. remember to add the port number when using TortoiseSVN.
6. test the svn server
Enter the website root directory
Cd/www/web/repos/public_html
Svn co svn: // 127.0.0.1: 3690/www/web/repos/public_html -- username pm -- password pm_pw
The following authentication prompt appears:
-----------------------------------------------------------------------
Note! Your password, for the authentication domain:
Repos
Only files on disks can be stored in plain text! If possible, consider configuring your system to make Subversion
You can save the encrypted password. See the documentation for details.
You can set the option "store-plaintext-passwords" to "yes" or "no" in "/root/. subversion/servers ",
To avoid this warning again.
-----------------------------------------------------------------------
Save unencrypted password (yes/no )?
Enter "yes" and press Enter. because no files have been added to the version repository, the version is 0, as shown below:
Obtain version 0.
III. configuration Post-commit To achieve automatic synchronization. Svn Version library file Web Directory
In order to directly synchronize the code submitted to the SVN server after modification, the WEB server needs to configure the SVN hook to enter the hooks directory,
Cd/opt/svndata/repos/hooks
Ls
You can see that there is a post-commit.tmpl file, this is a template file, copy a copy under this directory, name it post-commit, and set its user group to www, and set it to executable:
Cppost-commit.tmpl post-commit
Chown www: www post-commit
Chmod + x post-commit
In this way, you have the permission to access the www directory.
All the original code in the file is commented out. you can run the shell command to call this file every time the commit is completed.
The file content can be found below:
Vi post-commit
#! /Bin/sh
Export LANG = zh_CN.UTF-8
REPOS = "$1"
REV = "$2"
SVN_PATH =/usr/bin/svn
WEB_PATH =/web/repos/public_html
LOG_PATH =/tmp/svn_update.log
#/Usr/bin/svn update -- username user -- password $ WEB_PATH -- no-auth-cache
Echo "\ n ######### start to submit" 'date "+ % Y-% m-% d % H: % M: % S "'' ####################'> $ LOG_PATH
Echo 'whoam', $ REPOS, $ REV> $ LOG_PATH
$ SVN_PATH update -- username user -- password $ WEB_PATH -- no-auth-cache> $ LOG_PATH
Chown-R www: www $ WEB_PATH
Note:
1 ,#! /Bin/sh: run the shell command/* to set the environment variable. If no environment variable is set, an update error may occur */
2, export LANG = zh_CN.UTF-8 is to solve svn post commit Chinese garbled.
If you are GBK encoded, you may prompt: Error output cocould not be translated from the native locale to UTF-8
This is the client and server encoding problem, the default is UTF-8, you can try to set export LANG = zh_CN.GBK or export LANG = en_US.UTF-8
# Update
3. svn update-username the username of your version Library-password username password svn: // your IP address: Port/web/repos/public_html
4. chown-R www: www $ WEB_PATH
All the original code in the file is commented out. you can run the shell command to call this file every time the commit is completed.
This tutorial is taken from the wdlinux Forum ~