All Products
Search
Document Center

Elastic Compute Service:deploying and using SVN

Last Updated:Jan 02, 2025

Subversion (SVN) is an open-source version control system that efficiently manages data changes over time through a branching management system. This topic describes how to deploy and use SVN on ECS.

Preparations

Create an ECS instance for deploying SVN. For more information, see Custom Purchase Instance.

The instance must meet the following requirements:

  • The instance is assigned a static public IP address or associated with an Elastic IP Address (EIP). If you are not sure how to enable public access, see Enable Public Access.

  • Operating system: Alibaba Cloud Linux 3, Alibaba Cloud Linux 2, or CentOS 7.x.

  • Instance type: The instance type required for deploying the SVN service depends on the project specifications and team size. It is recommended to use an instance type with 4 vCPUs and 4 GiB or more.

  • An inbound rule is added to a security group of the instance to allow traffic on ports 22, 80, and 443. For more information, see Add Security Group Rules.

    Note

    If you want to access SVN using svnserve, add an inbound security group rule to open port 3690.

Deploy SVN

SVN supports two access modes: HTTP and svnserve. The main differences between these two modes are as follows. Choose one of the following deployment methods based on your business needs.

Feature

HTTP Mode

svnserve Mode

Protocol

HTTP for communication.

Custom SVN protocol for communication.

Access Method

Web browsers or clients.

Clients only.

Port

Port 80 for communication.

Port 3690 for communication.

Security

HTTPS for encrypted communication.

Plaintext communication by default. Encryption settings can be applied for secure communication.

Configuration

Configurations on the web server.

Configurations on the SVN server.

Supported Capabilities

More features, such as access control and log query.

Fewer and simpler features.

Deploy SVN over HTTP

Step 1: Install SVN

  1. Connect to the Linux instance where you want to install SVN.

    For more information, see Log on to a Linux Instance Using SSH in Workbench.

  2. Run the following command to install SVN.

    sudo yum install -y subversion
  3. Run the following command to check the SVN version.

    svnserve --version

    The output confirms that SVN is installed.

    Check SVN Version

Step 2: Install Apache

  1. Run the following command to install Apache HTTP Server (httpd).

    sudo yum install httpd -y
  2. Run the following command to check the httpd version.

    httpd -version

    The output confirms that httpd is installed.

    image.png

Step 3: Install mod_dav_svn

mod_dav_svn is an Apache HTTP Server module that enables web access to SVN repositories.

Run the following command to install mod_dav_svn.

sudo yum install mod_dav_svn -y

Step 4: Configure SVN

  1. Run the following commands in sequence to create an SVN repository.

    sudo mkdir /var/svn
    cd /var/svn
    sudo svnadmin create /var/svn/svnrepos
  2. Run the following command to change the ownership of the SVN repository to the apache user.

    sudo chown -R apache:apache /var/svn/svnrepos
  3. Run the following commands in sequence to verify the automatically generated files in the SVN repository.

    cd svnrepos
    ls

    Verify Repository Files

    The following table describes the directories and files in an SVN repository:

    Folder

    Description

    db

    Stores all version control data files.

    hooks

    Stores hook scripts.

    locks

    The directory that stores the SVN repository lock files and can be used to track accesses to the repository.

    format

    The text file that contains a single integer value. The value indicates the version number of the current SVN repository.

    conf

    The SVN repository configuration file that stores the usernames and access permissions of the repository.

  4. Run the following command to set a username and password for the SVN repository.

    SVN passwords are stored in plaintext. Since HTTP does not support plaintext passwords, create a separate file named passwd. In this example, add a user named userTest with the password passWDTest. Use one of the following commands based on your situation:

    • To add the first user to the SVN repository, use the -c parameter to create the file.

      sudo htpasswd -c /var/svn/svnrepos/conf/passwd userTest
    • To add additional users, use the following command:

      sudo htpasswd /var/svn/svnrepos/conf/passwd userTest

    Enter the password for the user when prompted.

  5. Navigate to the conf directory of the SVN repository.

    cd /var/svn/svnrepos/conf/
  6. Set read and write permissions for the user.

    1. Open the access control file with the following command:

      sudo vim authz
    2. Press i to enter edit mode.

    3. At the end of the file, add the following lines to grant read (r) and write (w) permissions to the user (userTest):

      [/]
      userTest=rw

      svn-4

    4. Press Esc and type :wq to save and exit.

  7. Modify the SVN configuration file.

    1. Open the SVN configuration file with the following command:

      sudo vim svnserve.conf
    2. Press i to enter edit mode.

    3. Remove the number sign (#) and spaces from the start of the following lines:

      Note

      Ensure no spaces precede the lines and that there is a space before and after the equal sign (=).

      anon-access = read
      auth-access = write
      password-db = passwd
      authz-db = authz
      realm = /var/svn/svnrepos

      image

    4. Press Esc and type :wq to save and exit.

  8. Start the SVN service with the following command, specifying the absolute path to the SVN repository:

    The following example command specifies the absolute path to the SVN repository.

    sudo svnserve -d -r /var/svn/svnrepos/
    Note

    To stop the SVN service, run the killall svnserve command.

  9. Verify that the SVN service has started with the following command:

    ps -ef |grep svn

    The output shown below indicates that the SVN service is running.Check SVN Service Status

Step 5: Configure Apache

  1. Add and edit the Apache configuration file with the following command:

    sudo vim /etc/httpd/conf.d/subversion.conf
  2. Press i to enter edit mode.

  3. Enter the following configuration information in the subversion.conf file:

    <Location /svn>
    DAV svn
    SVNParentPath /var/svn
    AuthType Basic
    AuthName "Authorization SVN"
    AuthzSVNAccessFile /var/svn/svnrepos/conf/authz
    AuthUserFile /var/svn/svnrepos/conf/passwd
    Require valid-user
    </Location>
  4. Press Esc and type :wq to save and exit.

  5. Start the Apache service with the following command:

    sudo systemctl start httpd.service

Deploy svnserve access to SVN

Step 1: Install SVN

  1. Connect to the Linux instance where you want to install SVN.

    For more information, see Log on to a Linux Instance Using SSH in Workbench.

  2. Run the following command to install SVN.

    sudo yum install -y subversion
  3. Run the following command to check the SVN version.

    svnserve --version

    The output confirms that SVN is installed.

    Check SVN Version

Step 2: Configure SVN

  1. Run the following commands in sequence to create an SVN repository.

    sudo mkdir /var/svn
    cd /var/svn
    sudo svnadmin create /var/svn/svnrepos
  2. Run the following commands in sequence to verify the automatically generated files in the SVN repository.

    cd svnrepos
    ls

    Verify Repository Files

    The following table describes the directories and files in an SVN repository:

    Folder

    Description

    db

    Stores all version control data files.

    hooks

    Stores hook scripts.

    locks

    The directory that stores the SVN repository lock files and can be used to track accesses to the repository.

    format

    The text file that contains a single integer value. The value indicates the version number of the current SVN repository.

    conf

    The SVN repository configuration file that stores the usernames and access permissions of the repository.

  3. Set the SVN repository username and password.

    1. Open the user configuration file with the following command:

      cd conf/
      sudo vim passwd
    2. Press i to enter edit mode.

    3. Under [users], add the username and password in the following format: username = password. For example, userTest = passWDTest.

      Note

      Add a space before and after the equal sign (=).

      svn-3

    4. Press Esc and type :wq to save and exit.

  4. Set read and write permissions for the user.

    1. Open the access control file with the following command:

      sudo vim authz
    2. Press i to enter edit mode.

    3. At the end of the file, add the following lines to grant read (r) and write (w) permissions to the user (userTest):

      [/]
      userTest=rw

      svn-4

    4. Press Esc and type :wq to save and exit.

  5. Modify the SVN configuration file.

    1. Open the SVN configuration file with the following command:

      sudo vim svnserve.conf
    2. Press i to enter edit mode.

    3. Remove the number sign (#) and spaces from the start of the following lines:

      Note

      Ensure no spaces precede the lines and that there is a space before and after the equal sign (=).

      anon-access = read
      auth-access = write
      password-db = passwd
      authz-db = authz
      realm = /var/svn/svnrepos

      image

    4. Press Esc and type :wq to save and exit.

  6. Start the SVN service with the following command, specifying the absolute path to the SVN repository:

    The following example command specifies the absolute path to the SVN repository.

    sudo svnserve -d -r /var/svn/svnrepos/
    Note

    To stop the SVN service, run the killall svnserve command.

  7. Verify that the SVN service has started with the following command:

    ps -ef |grep svn

    The output shown below indicates that the SVN service is running.Check SVN Service Status

Use SVN

This section describes the steps to manage code in SVN:

  1. Checkout: Create a working copy of the source code on your local device by checking out from the SVN repository.

  2. Other users may modify and commit changes to the source code in the repository.

  3. Update: Retrieve the latest version of the source code from the repository to your local working copy.

  4. Modify and debug the source code in your local working copy.

  5. Commit: Submit your changes to the repository so that other users can access the updated code.

Check out source code to a local directory (Checkout)

  1. You can download and install the TortoiseSVN client on your local Windows machine.

  2. Right-click in the local project folder and select SVN Checkout....

    For example, the project folder is C:\Test.

  3. In the pop-up menu, select SVN Checkout....

    snv-1

  4. Enter the repository URL and checkout directory, then click OK.

    • URL of Repository: The URL where the source code is stored.

      • HTTP access mode: To access via URL, use the format http://<ECS instance public IP>/svn/<SVN repository name>.

      • For svnserve access mode, the URL format is svn:///.

        Note

        If SVN is started in the directory above the SVN repository, include the repository name in the checkout URL.

    • Checkout Directory: The directory to which the source code is checked out. In this example, the directory is C:\Test.

    svn-2

    Note

    On the first login, enter the username and password you set in the passwd file.

    Below is an illustration of the outcome after performing a checkout operation.svn-5

Obtain updates (Update)

After updates are made to the project in the SVN repository, right-click in the local project folder and select SVN Update to download the latest project files. The updates will be displayed.

image.png

Note

When you select SVN Update, all files in the project folder are overwritten. It is recommended to back up the project before updating to prevent data loss.

Commit changes (Commit)

To commit local modifications to the repository, follow these steps:

  1. Right-click in the project folder and select SVN Commit....

    image.png

  2. Enter comments for the changes, select the files to commit, and click OK.

    Your local changes are now committed to the SVN repository and will be reflected in the project.

    image.png

    Note
    • If a conflict arises because a newer version of a file exists in the repository, your commit will fail. To resolve this, back up your local project, check out the latest files from the SVN repository, make your changes locally, and then commit them to the repository.

    • If a file is deleted from the project you are committing, the following message will appear.Deleted File Message

Restore files

To restore a deleted file in SVN, follow these steps:

  1. Open the local project folder, right-click and select SVN Checkout... to check out data.

  2. Delete a file from the working copy.

  3. Depending on whether you have committed the delete operation to the SVN repository, use one of the following methods to restore the deleted file:

    • If the delete operation is not committed, right-click and select TortoiseSVN > Revert....

      image.png

    • If the delete operation is committed, the file is removed from the repository. To restore it, do the following:

      1. Right-click and select TortoiseSVN > Show Log to view the operation log.

      2. In the logs, find and click the deletion entry for the file to see its details.

        image.png

      3. Right-click the deleted file and select Save Revision To....

        image.png

      4. In the save dialog box, enter the file name and click Save (S) to restore the deleted file to its original location.image.png

  4. Return to the original folder and select SVN Commit... to synchronize the restored file with the repository.

FAQ

Why does an error message indicating that the host does not respond appear when using TortoiseSVN to access the SVN server?

image

The error message indicating that the host does not respond can be caused by the following:

  • The SVN server is not running.

  • The required ports for the SVN server are not open in the associated security group.

  • The firewalld service is active on the ECS instance, but it does not allow traffic on the ports required by the SVN server.

To troubleshoot the issue, perform the following steps:

  1. Verify the status of the SVN service.

    ps -ef |grep svn

    If the SVN service is running, you will see output similar to the image below. If not, start the SVN service using the command sudo svnserve -d -r /var/svn/svnrepos/.Check SVN Service Status

  2. Check if the security group rules for the ECS instance allow the SVN server's required ports.

    1. For HTTP mode: Ensure ports 22, 80, and 443 are open.

    2. For svnserve mode: Ensure ports 22, 80, 443, and 3690 are open.

  3. Check the status of the firewalld service.

    1. Determine if the firewalld service is active.

      sudo firewall-cmd --state 
      • If the command output displays not running, then the firewalld service is inactive and will not impact the SVN server.

      • If the command output displays running, the firewalld service has started, and you can proceed to the next step.

    2. Open the necessary ports, such as port 3690, in the firewalld rules for SVN.

      sudo firewall-cmd --add-port=3690/tcp --per
    3. To apply the new settings, reload the firewalld service configuration.

      sudo systemctl reload firewalld