SVN server Setup and synchronization with the Web root using SVN hooks

Source: Internet
Author: User
Tags svn client collabnet

    1. SVN schematic diagram


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/AE/wKiom1btBS7gaSf4AAI-hcTfgR4286.jpg "title=" Svn.jpg "alt=" Wkiom1btbs7gasf4aai-hctfgr4286.jpg "/>


2.SVN Server Build-up

1. See if SVN RPM -QA | GREP SUBVERSION 2 is installed. Install yum install  Subversion3. Test whether the installation was successful  /usr/bin/svnserve --version  if prompted with the following, indicating that the installation was successful  ------------------------- ------------- svnserve, Version  1.6.11  (r934486)      compiled in  Apr 11  2013,17:28:04    All rights reserved   (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 following repository back-end (FS)   modules are available: * fs_base :  modules can only operate the BDB repository. The  * fs_fs :  module works with the text file (FSFS) repository.    Cyrus SASL  certification is available.  --------------------------------------------------------------  Second, configure  1, create a new directory:repos  can be used to store all SVN files  mkdir -p /opt/svndata/repos  Note that 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 new repository (using Svnadmin create  Directory Warehouse path consistent with the new directory above)  svnadmin create /opt/svndata/repos    3, modify the SVN repository profile  vi /opt/svndata/repos/conf/svnserve.conf  #注意这个文件中的每一行与每一行之间的空格都必须删除 # The space before each line must also be deleted # otherwise it will be an error. #按以下格式内容修改, where the value of realm is the project name, in this case repos.  [general] anon-access = noneauth-access = writepassword-db = /opt/ svndata/repos/conf/passwdauthz-db = /opt/svndata/repos/conf/authzrealm =  Repos Note: Changes to the user profile take effect immediately and do not have to restart SVN.    4, add users  vi /opt/svndata/repos/conf/passwd  #要添加SVN用户非常简单, just/opt/svn/project/ CONF/PASSWD file add an entry with a shape such as "Username=pass#word" to it. #注意, the blank line of each line in this passwd file must also be deleted, and the space must be removed in order to test, I added the following:  [users] # harry = harryssecret#  sally = sallyssecretpm = pm_pwserver_group = server_pwclient_group =  client_pwtest_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: &nbsp [groups]project_p = pmproject_s = server_groupproject_c = client_groupproject_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* =  above information indicates that only PM has the root directory read and write rights, Server_group can access the server directory, Client_group can access the client directory, The doc directory is accessible to everyone.   Of course, the above is more complex permissions control, if only testing, can be simpler. Set up a user group, put all the users into a user group, as follows:  [groups]admin = pm,server_group,client_group,test_group  [ /]  @admin  = rw* =  Whether anonymous can access the key is to look at the "*" configuration. "* =" just doesn't have any permissions.   on the control of the rights, this article does not describe the details, we can go to counseling degrees Niang.    5, start SVN service  svnserve -d --listen-port 3690 -r /opt/svndata/repos   (running as root) boot: #echo   ' Svnserve -d --listen-port&nbsP;3690 -r /opt/svndata/repos '  >> /etc/rc.d/ Rc.local if more than one project is being developed at the same time, multiple SVN services can be opened via different ports, and the port number will be added when using TORTOISESVN operations. #停止SVN服务killall  svnserve6, test the SVN server into the Web site root directory cd /www/web/repos/public_htmlsvn co svn:// 127.0.0.1:3690 /www/web/repos/public_html --username pm --password pm_pwsvn  import . file:///data/svndata/peel.haochedai.com -m  "Import" The following authentication prompts will appear-----------------------------------------------------------------------note!   Your password for the authentication domain:     repos can only be saved on disk!   if possible, consider configuring your system so that  subversion can save the encrypted password. Please refer to the documentation for more information. You can avoid this warning again by setting the option "Store-plaintext-passwords" to "yes" or "no" in "/root/.subversion/servers". -----------------------------------------------------------------------Save an unencrypted password (yes/no)? Enter "Yes"   carriage return, Since the repository has not yet added any files, it is removed from version 0, as follows: Remove version  0. Third, configure the Post-commit, realize the automatic synchronization svn repository files to the Web directory in order to be able to after modifying the code submitted to the SVN server, the Web server to synchronize directly. Need to configure SVN hooks, enter the hooks directory, cd /opt/svndata/ Repos/hooksls can seeTo have a Post-commit.tmpl file, which is a template file, copy it in this directory, named Post-commit, and set its user group to WWW, and setup to execute:cp post-commit.tmpl  Post-commitchown www:www post-commitchmod +x post-commit this gives you permission to access the WWW directory. The original code in it is all commented out. You can execute the shell command here, and this file will be called each time the commit is completed. The contents of the file refer to the following: Vi post-commit#!/bin/shexport. Utf-8repos= "$" rev= "$" svn_path=/usr/bin/svnweb_path=/www/web/repos/public_htmllog_path=/tmp/svn_update.log# This row has been commented #/usr/bin/svn update --username user --password password  $WEB _path -- no-auth-cacheecho  "\n\n\n######### #开始提交  "   "date " +%y-%m-%d %h:%m:%s " " ######### ######### '  >> $LOG _pathecho  ' WhoAmI ', $REPOS, $REV  >>  $LOG _path# Note Change this line user and password to your specific user and password$svn_path update --username user --password  password  $WEB _path --no-auth-cache >>  $LOG _pathchown -r www:www  $WEB _ path======================================================================================== Description: 1, #!/bin/sh  instructions is to execute the shell command  /* set environment variables, if not set may appear update error */2, export. utf-8  is to solve the svn post commit  Chinese garbled. If you are GBK encoded may be prompted: error output could not be translated from the native  locale to utf-8 This is a problem with the client and server encoding, the default is Utf-8, you can try to set export. GBK or export.utf-8# perform the update operation 3, svn update –username  your repository username  –password  username password  svn:// Your IP address: port  /WEB/WEB/REPOS/PUBLIC_HTML4, chown -r www:www  $WEB _path  Change folder owner is suitable for web  The original code inside the server is commented out. You can execute the shell command, which is called every time the commit is completed.  ls * | file -convmv -f gbk -t utf-8 -r –notest   convmv  -f latin1 -t utf-8 * --notest




Next install the SVN client on the Windows client

Upload the file test, I uploaded the svn.ppt here


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7D/AB/wKioL1btB56zHKr_AABvLVmZM9g450.png "style=" float: none; "title=" Svn1.png "alt=" Wkiol1btb56zhkr_aabvlvmzm9g450.png "/>


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7D/AE/wKiom1btBwzQeOH0AAA_EyAClbY204.png "title=" 2.png " Style= "Float:none;" alt= "Wkiom1btbwzqeoh0aaa_eyaclby204.png"/>


650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M02/7D/AB/wKioL1btCMaSQXPYAAHHJcIqNVE829.png "title=" Svn4.png "alt=" Wkiol1btcmasqxpyaahhjciqnve829.png "/>

You can find that the uploaded file has been passed to the root of the website.


650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M02/7D/AE/wKiom1btB3WCvn4bAAAfHGL-K_I277.png "title=" 3.png " alt= "Wkiom1btb3wcvn4baaafhgl-k_i277.png"/>

This article is from the "clear" blog, make sure to keep this source http://duanyexuanmu.blog.51cto.com/1010786/1752888

SVN server Setup and synchronization with the Web root using SVN hooks

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.