Subversion Server. Howto
Here you can find how to prepare a subversion repository and its integration with Apache 2.
You need apache with webDAV to access repository content using HTTP or HTTPS protocol. If you prefer not to use apache, then you should use svnserve (prefered in daemon mode). This will mean using svn protocol.
Be careful with firewalls (see ahead).
And, of course, always better with Debian.
Subversion for repository administrators (using Apache 2)
In order to create a repository you need to follow these steps (do it in a root shell).
Install the needed packages:
- apache2
- subversion
- libapache2-svn
Add next rules to your host in Apache 2. In Debian a mostly equal config (that you should modify) exists under /etc/apache2/mods-available/dav_svn.conf
Configuration sniplet:
< Location /svn>
# Uncomment this to enable the repository,
DAV svn
# Set this to the path to your repository
# SVNPath /var/lib/svn
# SVNParentPath /var/lib/svn/repository
SVNPath /var/lib/svn/repository
# The following allows for basic HTTP authentication. Basic authentication
# should not be considered secure for any particularly rigorous definition of
# secure.
# to create a passwd file
# # rm -f /etc/apache2/dav_svn.passwd
# # htpasswd2 -c /etc/apache2/dav_svn.passwd dwhedon
# New password:
# Re-type new password:
# Adding password for user dwhedon
# #
# http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html
# configuration for mixed authenticated/anonymous access
Satisfy Any
Require valid-user
# Uncomment the following 3 lines to enable Basic Authentication
AuthType Basic
AuthName “Subversion Repository”
AuthUserFile /etc/apache2/dav_svn.passwd
# Uncomment the following line to enable Authz Authentication
# AuthzSVNAccessFile /etc/apache2/dav_svn.authz
# The following three lines allow anonymous read, but make
# committers authenticate themselves.
< LimitExcept GET PROPFIND OPTIONS REPORT>
Require valid-user
< /LimitExcept>
(Important: Don’t use a DocumentRoot setting for this virtual host!”)
Restart apache with or reload apache configuration without finishing open connections with (prefered)
root@maquine:~ $ /etc/init.d/apache2 reload
or
root@maquine:~ $ apache2ctl graceful (prefered)
Create the repository and create a password file:
root@maquine:~ $ svnadmin create /var/lib/svn/repository
root@maquine:~ $ htpasswd2 -c /etc/subversion/passwd [username]
root@maquine:~ $ chown -R www-data:www-data /home/svn
Don’t forget to make the repository accessible for your web server:
To test it, try accessing it with a browser or try to check out the file:
user@maquine:~ $ lynx http://localhost/svn
user@maquine:~ $ svn co http://server/svn
(You will not be prompted for credentials. That’s normal.)
Worked?
Voila. The repository is set up.
You can check a ready setup in http://www.eldemonionegro.com/svn/.
Subversion for repository administrators (using subversion protocol)
You just need to put on work svn server.
user@maquine:~ $ ls -la /var/lib/svn/
total 1
drwxr-xr-x 4 root www-data 96 2005-06-06 00:45 .
drwxr-xr-x 56 root root 1480 2005-06-03 17:00 ..
drwxr-x— 7 root www-data 224 2003-02-20 00:37 project1
drwxr-x— 7 root www-data 224 2004-11-15 21:23 project2
user@maquine:~ $ svnserve -d -T -r REPOSITORY_DIR (Example 1: /var/lib/svn/project1/ – Example 2: /var/lib/svn/)
(-d: daemon, -T: spawn a thread instead of a process for each connection, -r root: root repository)
Try to check out the file:
user@maquine:~ $ svn co REPOSITORY_URL (Example 1: svn://server/ – Example 2: svn://server/project1/)
Worked?
Voila. The repository is set up.
Subversion for repository users
To checkout (=download) the files in the repository for the very first time run this command::
user@maquine:~ $ svn co http://server/svn
Don’t worry about other people working on the same files. Just do your changes to the files and when you seem to have a stable state (make sure everything works well enough so not everything will break for others) you should check in(=upload) your work:
user@maquine:~ $ svn ci
(Only when committing your changes you will be prompted for your username and password.)
Run the following command regularly to get the changes from other contributors::
user@maquine:~ $ svn update
If you want to add new files to the repository::
user@maquine:~ $ svn add [filename]
To get a status of which files have changed::
user@maquine:~ $ svn stat
Subversion for local repositories
This type of installation is used when you want subversion to track your local files but don’t want/need to put it on a host. You can create a local repository and access it directly. This repository is not password protected and it’s permissions depend on the filesystem’s permissions.
Install the needed packages (as root or with sudo) and create the repository (with your user):
root@maquine:~ $ apt-get install subversion
root@maquine:~ $ svnadmin create /home/joe/repositorie
The URL to your repository is it’s path preceeded with file://. For example to checkout you would do the following:
user@maquine:~ $ svn co file:///home/joe/repositorie
Subversion firewall rules
In order to acces your subversion repository using svn protocol you should reconfigure your firewall or update daemon config.
If you need to access subversion remotely, by default it runs on port 3690 using TCP.
Resources and comments
- Subversion’s Official Homepage
- Online free book: Version Control with Subversion
- http://workaround.org/moin/SubVersion
Original Authors: Christoph Haas, Tiago Cogumbreiro
Modified by: Enrique Garcia
Te interesará:

Últimos comentarios