This topic describes how to deploy Apache Subversion (SVN) over HTTP.
Prerequisites
- An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the
Sign up to Alibaba Cloud page.
- An instance that runs a CentOS operating system is created. For more information,
see Creation method overview.
- Inbound rules are added to the security groups of the instance to allow traffic on
port 3690, which is the default port of SVN. For more information, see Add a security group rule.
Background information
In this topic, the following instance configurations and software versions are used
to manually deploy SVN. The procedure may vary based on your actual configurations.
- Instance type: ecs.c6.large
- Operating system: CentOS 7.2 64-bit public image
- SVN: 1.7.14
- Apache HTTP Server: 2.4.6
You can also use Alibaba Cloud Marketplace images to deploy SVN. For example, you
can use SVN images provided by Alibaba Cloud Marketplace to deploy SVN. For more information,
see the "User guide" section on the SVN version control (CentOS 64-bit) page.
Step 1: Install SVN
- Connect to the Linux instance. For more information, see Connect to a Linux instance by using a password.
- Run the following command to install SVN:
yum install subversion -y
- Run the following command to check the SVN version:
Step 2: Install Apache
- Run the following command to install httpd:
- Run the following command to check the httpd version:
Step 3: Install mod_dav_svn
Run the following command to install mod_dav_svn:
yum install mod_dav_svn -y
Step 4: Configure SVN
- Run the following commands in sequence to create an SVN repository:
mkdir /var/svn
cd /var/svn
svnadmin create /var/svn/svnrepos
- Run the following command to change the user group of the SVN repository to apache:
chown -R apache:apache /var/svn/svnrepos
- Run the following commands in sequence to check the files that are automatically generated
in the SVN repository:
cd svnrepos
ls

The following table describes the SVN directories and files.
Directory and file |
Description |
db |
Stores all version control data files. |
hooks |
Stores hook scripts. |
locks |
The client used to track access to the SVN repository. |
format |
The text file that contains a single integer value. The value indicates the version
number of the current SVN repository.
|
conf |
The configuration file of the SVN repository, which stores the usernames and permissions
for accessing the repository.
|
- Run the following command to add a username and password for the SVN repository.
By default, the password for SVN is stored as plaintext. You must separately generate
a passwd file for HTTP because HTTP does not support plaintext passwords. In this
example, the added username is
userTest
and the password is
passWDTest
. Run one of the following commands:
Set the password of the user.
- Run the following command to go to the conf directory:
cd /var/svn/svnrepos/conf/
- Configure the read and write permissions for the account.
- Run the
vi authz
command to open the access control file.
- Press the
I
key to enter the edit mode.
- Move the pointer over the end of the file and add the following code. In the code,
userTest specifies the username, r specifies the read permissions, and w specifies
the write permissions.
[/]
userTest=rw

- Press the
Esc
key to exit the edit mode and enter :wq
to save and close the file.
- Modify the configurations of SVN.
- Run the
vi svnserve.conf
command to open the configuration file of SVN.
- Press the
I
key to enter the edit mode.
- Move the pointer over the following lines and delete the number sign (#) and space
from the beginning of each line.
Note Lines cannot start with a space. You must add a space before and after the equal sign
(=).
anon-access = read # Grant read permissions to anonymous users. You can also set anon-access to none to deny access by anonymous users. If you set anon-access to none, the operation dates in the SVN log can be shown properly.
auth-access = write # Grant write permissions.
password-db = passwd # Specify the password database file.
authz-db = authz # Specify the file that stores the authorization rules for path-based access control.
realm = /var/svn/svnrepos # Specify the authorization realm of the SVN repository.

- Press the
Esc
key to exit the edit mode and enter :wq
to save and close the file.
- Run the following command to start the SVN repository:
The absolute path to the SVN repository is specified in the following example command:
svnserve -d -r /var/svn/svnrepos/
Note You can run the killall svnserve
command to stop SVN.
- Run the
ps -ef |grep svn
command to check whether SVN is started.
A command output similar to the following one indicates that SVN is started.

Step 5: Configure Apache
- Run the following command to add and edit the httpd configuration file:
vim /etc/httpd/conf.d/subversion.conf
- Press the
I
key to enter the edit mode.
- Enter the following configurations:
<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>
- Press the
Esc
key and enter :wq
to save and close the file.
- Run the following command to start the Apache service:
systemctl start httpd.service
Step 6: Use a browser to test the access to SVN
- Open the browser in your computer.
- In the address bar, enter a URL in the
http://<Public IP address of the ECS instance>/svn/<SVN repository name>
format and press the Enter key. In this example, the SVN repository name is svnrepos.
- Enter your username and password that you configured in the passwd file. In this example, the username is userTest and the password is passWDTest.
The following command output indicates that the created SVN repository is accessed.
