Build and use SVN servers under CentOS

Source: Internet
Author: User
Tags svn client

As a new generation of code version management tools, SVN has many advantages, such as convenient management, clear logic, high security, and high code consistency. SVN data storage has two methods: BDB Transaction Security table type) and FSFS, which do not require a database storage system). To avoid locking data when the server connection is interrupted, FSFS is a safer and more popular method. There are two ways to run SVN: one is an independent server, and the other is to use the apache service, each of which has its own advantages and disadvantages. The following describes the respective deployment steps of the two methods.

1. run as an independent server:

① Install svn using the local yum source. yum install svn is included in the operating system image. For detailed steps, see http://ailurus.blog.51cto.com/4814469/1168336;

② Create a version Library:

 
 
  1. Mkdir/svn/project // folder where the version library is created
  2. Svnadmin create -- fs-type fsfs/svn/project/first
  3. // Create a version library. If you need to store it in bdb mode, change fsfs to bdb.

③ Initialize the version library, that is, import the file to the version Library:

 
 
  1. Svn import/home/software file: // svn/project/first -- message "initialization version"
  2. // Import the files in the home folder to the version Library
  3. Svn list -- verbose file: // svn/project/first // view the imported file

④ Start the svn service. The default port of the svn service is 3690. You can run the "netstat-ntlp" command to check whether the service is successfully started:

 
 
  1. svnserve -d -r /svn/project/first 

⑤ Modify the policy control file vi authz. If you want to add a user later, add the user name to the corresponding user group admin or user:

 
 
  1. ### This file is an example authorization file for svnserve.
  2. ### Its format is identical to that of mod_authz_svn authorization
  3. ### Files.
  4. ### As shown below each section defines authorizations for the path and
  5. ### (Optional) repository specified by the section name.
  6. ### The authorizations follow. An authorization line can refer:
  7. ###-A single user,
  8. ###-A group of users defined in a special [groups] section,
  9. ###-An alias defined in a special [aliases] section,
  10. ###-All authenticated users, using the '$ authenticated' token,
  11. ###-Only anonymous users, using the '$ anonymous' token,
  12. ###-Anyone, using the '*' wildcard.
  13. ###
  14. ### A match can be inverted by prefixing the rule '~ '. Rules can
  15. ### Grant read ('R') access, read-write ('rw ') access, or no access
  16. ###('').
  17.  
  18. [Aliases]
  19. # Joe =/C = XZ/ST = Dessert/L = Snake City/O = Snake Oil, Ltd./OU = Research Institute/CN = Joe Average
  20.  
  21. [Groups]
  22. # Harry_and_sally = harry, sally
  23. # Harry_sally_and_joe = harry, sally, & joe
  24. Admin = first, second, third // members of the user group admin
  25. User = anyone // Member of the user group
  26.  
  27. # [/Foo/bar]
  28. # Harry = rw
  29. # & Joe = r
  30. # * =
  31.  
  32. # [Repository:/baz/fuz]
  33. # @ Harry_and_sally = rw
  34. # * = R
  35.  
  36. [/]
  37. @ Admin = rw // members in the user group admin have read and write permissions
  38. @ User = r // members in the user group have the read permission

6. Add the svn access user, vi passwd, set the password for the user allocated in authz, the user name on the left of the equal sign, and the password on the right of the equal sign;

 
 
  1. ### This file is an example password file for svnserve. 
  2. ### Its format is similar to that of svnserve.conf. As shown in the 
  3. ### example below it contains one section labelled [users]. 
  4. ### The name and password for each user follow, one account per line. 
  5.  
  6. [users] 
  7. # harry = harryssecret 
  8. # sally = sallyssecret 
  9.  
  10. first=first 
  11. second=second 
  12. third=third 
  13. anyone=anyone 

7. Modify the Permission Policy file read by svn, vi/svn/project/first/conf/svnserve. conf:

 
 
  1. Anon-access = none // anonymous users are not allowed to read and write
  2. Auth-access = write
  3. Password-db = passwd // passwd file read by svn
  4. Authz-db = authz // permission Control File Read by svn

After installing the svn client, you can use the following url to access the client:

Svn: // ip address/svn/project/first

2. Access svn through the web through the apache server:

① Install two svn plug-ins on the apache server. The two plug-ins can also be installed using yum:

 
 
  1. Yum install mod_dav_svn // enables subversion to communicate with the dav Module
  2. Yum install mod_authz_svn // implement the permission Control Function

② Run the "httpd-M" command to check whether the two modules are loaded. If the two modules are loaded, the following response is returned:

 
 
  1. Loaded Modules: 
  2.  core_module (static) 
  3.  mpm_prefork_module (static) 
  4.  http_module (static) 
  5.  so_module (static) 
  6.  auth_basic_module (shared) 
  7.  auth_digest_module (shared) 
  8.  authn_file_module (shared) 
  9.  authn_alias_module (shared) 
  10.  authn_anon_module (shared) 
  11.  authn_dbm_module (shared) 
  12.  authn_default_module (shared) 
  13.  authz_host_module (shared) 
  14.  authz_user_module (shared) 
  15.  authz_owner_module (shared) 
  16.  authz_groupfile_module (shared) 
  17.  authz_dbm_module (shared) 
  18.  authz_default_module (shared) 
  19.  ldap_module (shared) 
  20.  authnz_ldap_module (shared) 
  21.  include_module (shared) 
  22.  log_config_module (shared) 
  23.  logio_module (shared) 
  24.  env_module (shared) 
  25.  ext_filter_module (shared) 
  26.  mime_magic_module (shared) 
  27.  expires_module (shared) 
  28.  deflate_module (shared) 
  29.  headers_module (shared) 
  30.  usertrack_module (shared) 
  31.  setenvif_module (shared) 
  32.  mime_module (shared) 
  33.  dav_module (shared) 
  34.  status_module (shared) 
  35.  autoindex_module (shared) 
  36.  info_module (shared) 
  37.  dav_fs_module (shared) 
  38.  vhost_alias_module (shared) 
  39.  negotiation_module (shared) 
  40.  dir_module (shared) 
  41.  actions_module (shared) 
  42.  speling_module (shared) 
  43.  userdir_module (shared) 
  44.  alias_module (shared) 
  45.  substitute_module (shared) 
  46.  rewrite_module (shared) 
  47.  proxy_module (shared) 
  48.  proxy_balancer_module (shared) 
  49.  proxy_ftp_module (shared) 
  50.  proxy_http_module (shared) 
  51.  proxy_ajp_module (shared) 
  52.  proxy_connect_module (shared) 
  53.  cache_module (shared) 
  54.  suexec_module (shared) 
  55.  disk_cache_module (shared) 
  56.  cgi_module (shared) 
  57.  version_module (shared) 
  58.  authz_ldap_module (shared) 
  59.  dav_svn_module (shared) 
  60.  authz_svn_module (shared) 
  61. Syntax OK 

③ Edit the apache service configuration file vi/etc/httpd/conf/httpd. conf and add the following lines:

 
 
  1. <Location/svn>
  2. DAV svn
  3. SVNPath/svn/project/first
  4. AuthzSVNAccessFile/etc/httpd/conf. d/authz
  5. // Permission policy file read by the apache server
  6. AuthType Basic
  7. AuthName "Project"
  8. AuthUserFile/etc/httpd/conf. d/passwd
  9. // Password storage file read by the apache server
  10. Require valid-user

④ Put the edited file authz in the folder/etc/httpd/conf. d, the file format is the same as the authz File above the article, editing the file passwd put in the folder/etc/httpd/conf. d, use the following command to generate the user name and password:

 
 
  1. Htpasswd-c/svn/project/first admin
  2. // The command is htpasswd,-c is the parameter,/svn/project/first is the accessed version library, and admin is the user name

Then, repeat the password you want to set to automatically store it in the file passwd. The default value is md5.

⑤ Restart the apache service to access the service by using the username and password you just set on the webpage. The URL is http: // ip address: Port/svn.

This article is from the "Rainbow cat walking across the world" blog!

Related Article

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.