|
First, install
yum install subversion test whether the installation was successful
/ Usr / bin / svnserve --version as tips below, indicating that it has successfully installed
svnserve, version 1.6.11 (r934486)
Compiled on May 14 2012,05: 36: 26
Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/ site.
This product includes the CollabNet (http://www.Collab.Net/) software developed.
The following repository back - end (FS) modules are available:
* Fs_base: module can only be operated BDB repository.
* Fs_fs: module with text file (FSFS) repository to work together.
Cyrus SASL authentication available.
Second, the configuration
1, create a new directory: repos, it can be used to store all the files in SVN
mkdir -p / opt / svn / repos
2, a new version of the warehouse
svnadmin create / opt / svn / repos
3, the version in the repository initialization
mkdir project project / server project / client project / test (temporary directory)
svn import project / file: /// opt / svn / repos / project -m 'initialization svn directory'
rm -rf project (optional useless if the project can be deleted)
4, modify the configuration file svn repository
vim /opt/svn/repos/conf/svnserve.conf
Content is amended as follows:
[General]
anon-access = none
auth-access = write
password-db = / opt / svn / project / conf / passwd
authz-db = / opt / svn / project / conf / authz
realm = LAMP100 repos
Note: The changes to the user profile take effect immediately, without restarting svn.
5, adding users
To add SVN users is as simple as in / opt / svn / project / conf / passwd file to add a form such as "username = password" entry on it for testing purposes, I added the following:
[Users]
# Harry = harryssecret
# Sally = sallyssecret
pm = pm_pw
server_group = server_pw
client_group = client_pw
test_group = test_pw
6, modify user access policies
/ Opt / svn / project / conf / authz record user access policies, the following 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 shows that only pm read and write to the root directory,
server_group be able to access the directory server,
client_group client can access the directory,
Everyone can access the doc directory.
7, start svn service
svnserve -d --listen-port 9999 -r / opt / svn (run as root)
8, test svn server
cd / web /
svn co svn: //192.168.10.10/repos/project
Authentication LAMP100 repos: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Password for 'root':
Authentication LAMP100 repos: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Username: server_group
Password for 'server_group':
svn: Authorization failed (access server_group useless root directory)
# Svn co svn: //192.168.10.10/repos/project
Authentication LAMP100 repos: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Password for 'root':
Authentication LAMP100 repos: 92731041-2dae-4c23-97fd-9e1ed7f0d18d
Username: pm
Password for 'pm':
A project / test
A project / server
A project / client
Checked out revision 1. (test successfully extracted)
# Cd project / server
# Vim index.php
# Svn add index.php
# Svn commit index.php -m "test my PHP program"
Adding index.php
Transmitting file data.
Committed revision 2. (test successfully submitted)
Third, configure the post-commit, automatic synchronization svn repository files to the web directory
To be able to modify the code after submission to the SVN server, WEB server is directly synchronized to configure SVN hooks, open hooks directory,
You can see there is a post-commit.tmpl file, which is a template file,
Copy in this directory named post-commit, and user groups to www, and set the executable:
chown www: www post-commit
chmod + x post-commit This will have access to the www directory.
Inside the original code is commented out. Here you can execute shell commands, each file will be called after the commit is complete.
My content file as follows:
#! / Bin / sh
# Set the environment variable, if not set update error may occur
export LANG = zh_CN.UTF-8
REPOS = "$ 1"
REV = "$ 2"
SVN_PATH = / usr / bin / svn
WEB_PATH = / web / project
LOG_PATH = / tmp / svn_update.log
# / Usr / bin / svn update --username user --password password $ WEB_PATH --no-auth-cache
echo "nnn ########## begin submitting" `date" +% Y-% m-% d% H:% M:% S "` '########### ####### '>> $ lOG_PATH
echo `whoami`, $ REPOS, $ REV >> $ LOG_PATH
$ SVN_PATH update --username user --password password $ WEB_PATH --no-auth-cache >> $ LOG_PATH
chown -R www: www $ WEB_PATH
Explanation:
1, #! / Bin / sh shell command instructions are executed
2, export LANG = zh_CN.UTF-8 in order to solve svn post commit Chinese garbled.
If you are GBK coding may be prompted: Error output could not be translated from the native locale to UTF-8
This is the client and the server coding problems, the default is utf-8, you can try to set export LANG = zh_CN.GBK or export LANG = en_US.UTF-8
# Perform updates
3, svn update -username your repository username username -password password svn: // your IP address: port / repos / project / web / project
4, chown -R www: www $ WEB_PATH change the folder owner to the appropriate Web Server
Inside the original code is commented out. Here you can execute shell commands, each file will be called after the commit is complete. |
|
|
|