This topic describes how to deploy access to Apache Subversion (SVN) by using svnserve.

Prerequisites

You must have an Alibaba Cloud account before you follow the instructions provided in the tutorial. To create an Alibaba Cloud account, click Create an Alibaba Cloud account.

Background information

In this topic, the following software versions are used to manually deploy SVN. The versions may be different in your actual running environment.
  • Operating system: public image 64-bit CentOS 7.2
  • Subversion: version 1.7.14
  • Apache HTTP Server: version 2.4.6

Procedure

Step 1: Install SVN

You can install SVN in any of the following ways:
  • Use an SVN image from Alibaba Cloud Marketplace
    1. Click here to purchase an SVN image in Alibaba Cloud Marketplace.
    2. Click Choose Your Plan.
    3. Enter the account and password to log on to the ECS console.
    4. In the Image section, the Selected Image field shows the specified SVN image. Continue with other settings and activate the ECS instance. For more information, see Create an instance by using the wizard.
  • Install SVN manually
    1. Connect to a Linux instance by using a password.
    2. Run the following command to install SVN.
      yum install subversion
    3. Run the following command to check the SVN version.
      svnserve --version

      Check the SVN version

Step 2: Configure SVN

To configure SVN, follow these steps:

  1. Run the following command to create a root directory for an SVN repository.
    mkdir /var/svn
  2. Run the following commands in sequence to create an SVN repository.
    # cd /var/svn
    # svnadmin create /var/svn/svnrepos
  3. Run the following commands in sequence to check files in the SVN repository.
    # cd svnrepos
    # ls

    Check files in the SVN repository
    The SVN directories are described as follows:
    Directory Description
    db Stores all version control data files.
    hooks Stores hook scripts.
    locks The client used to track access to the SVN repository.
    format A text file that contains only one integer, indicating the version number of the current SVN repository.
    conf The configuration file of the SVN repository, including the username and permissions for accessing the repository.
  4. Set the username and password of the SVN repository.
    1. Run the cd conf/ command.
    2. Run the vi passwd command to open the configuration file.
    3. Press the i key to enter the edit mode.
    4. Move the pointer to the [users] field, and add the username and password.
      Note You can add the username and password in the following format: username = password. For example, suzhan (username) = redhat (password), as shown in the following figure. There must be a space on both ends of the equal sign (=).

      Add the username and password
    5. Press the Esc key to exit the edit mode, and type :wq to save and close the file.
  5. Set the read and write permissions for the username.
    1. Run the vi authz command to open the permission control file.
    2. Press the i key to enter the edit mode.
    3. Move the pointer to the end of the file, and add the following code. In the code, suzhan specifies the username, r specifies the read permission, and w specifies the write permission.
      [/]
      suzhan=rw
    4. Press the Esc key to exit the edit mode, and type :wq to save and close the file.

      Set the read and write permissions for the username
  6. Modify the configurations of the SVN service.
    1. Run the command vi svnserve.conf to open the configuration file of the SVN service.
    2. Press the i key to enter the edit mode.
    3. Move the pointer to the following lines, and delete the number sign (#) and space at the beginning of each line:
      anon-access = read #Assigns read permissions to anonymous users. You can also specify anon-access = none to disable access by anonymous users. If you set anon-access to none, the revision history of the SVN service shows dates.
      auth-access = write #Authorizes the write permission.
      password-db = passwd #Specifies the password database file.
      authz-db = authz #Specifies the file that stores the authorization rules for path-based access control.
      realm = /var/svn/svnrepos #Specifies the authorization realm of the repository.
      Note Each line cannot start with a space and there must be a space on both ends of the equal sign (=).

      Modify the configurations of the SVN service
    4. Press the Esc key to exit the edit mode, and type :wq to save and close the file.
  7. Run the following command to start the SVN repository.
    svnserve -d -r /var/svn/
  8. Run the command ps -ef |grep svn to check whether the SVN service has been started.
    The following response indicates that the SVN service has been started.
    Check the SVN service status
    Note Run the command killall svnserve to stop the SVN service.

Step 3: Configure the security group rules

The SVN server listens on TCP Port 3690 by default. You must log on to the ECS console to add TCP Port 3690 to the security group. For more information, see Add security group rules.

Step 4: Use a Windows client to test the SVN service

To test the SVN service by using a Windows client, follow these steps:

  1. Download and install a TortoiseSVN client on your local computer.
  2. Right-click the local project folder. In this example, the project folder is C:\KDR.
  3. On the menu that appears, select SVN Checkout.
  4. Apply the following settings, and click OK.
    • Set the URL of repository field in this format: svn://Public IP address of the ECS instance/SVN repository name. In this example, the SVN repository name is svnrepos.
    • Set the Checkout directory field. In this example, the directory is C:\KDR.

    Checkout settings
    Note During the logon for the first time, you must provide the username and password that you have configured in the passwd file.