How to create
SVN repositoryand synchronizing files to the Web
Catalogue
To source : Empty Valley
One install and configure SVN
1. Install Subversion
Centos:yum Install Subversionubuntu:apt-get Install Subversion
2. Build the repository, in this case our repository is built on/VAR/SVN, assuming the repository directory is: foo
Cd/varmkdir svnsvnadmin Create Foo
3. Configuring the Repository
Just set up the repository, you need to configure the authentication method, user name and password, permissions to configure the three files, respectively, corresponding to the/var/svn/foo/conf
SVNSERVE.CONF,PASSWD and Authz these three files.
Svnserve.conf (uncomment) anon-access = noneauth-access = writepassword-db = Passwdauthz-db = authz.conf
Realm = Fill in the authentication domain name at login prompt
Add the appropriate user name and password to the passwd file:
User1 = Password1user2 = Password2
If you want to use a common user name password and permission authentication, specify the PASSWORD-DB and authz-db paths to the appropriate passwd and authz.conf file locations
Authz file Add the appropriate user name to the group and assign the library permissions:
[Groups]foo_user = User1,user2 (multiple users separated by commas) [/] @foo_user = rw* =
Where *= means that anonymous users do not have permission to refer to the group name with the @ symbol
4. Start-Up and use
After the configuration is successful, start the SVN repository Service
Svnserve-d-R/VAR/SVN
Get repository:
SVN Co SVN://IP address/foo
SVN co File:///var/svn/foo can be used directly on the server
Second, synchronize to the Web directory
1. Create a Web directory (the existing directory is skipped)
Cd/varmkdir Wwwchmod 777 www
2. Check out the copy to/var/www
SVN Co file:///var/svn/foo
3. Add hooks (Hook) file
In the/var/svn/foo/hooks/ directory
# Start-commit triggers a transaction before committing
# Pre-commit triggers transaction before commit completes
# Post-commit triggers transaction when commit is complete
# Pre-revprop-change triggers a transaction before the Version property is modified
# Post-revprop-change triggers a transaction after the version property has been modified
We only need to modify the Post-commit file here:
CP Post-commit.tmpl Post-commit
Edit the file
#!/bin/sh# Configuration Library Address repos= "$1″rev=" $2″# Web directory basepath=/var/www# Web folder name same as SVN library name name=$ (basename $REPOS) webpath= "$ basepath/$NAME "# to avoid Chinese information garbled export lang=" ZH_CN. utf-8″# can update the specified directory with the svnlook command SVN update $WEBPATH –username=user1–password=password1–no-auth-cache
After saving, you need to modify the Post-commit file permission to 755, otherwise SVN cannot invoke execution
chmod 755 Post-commit
SVN sync repository with Site Directory