Not only in my opinion, the preferred configuration of using SVNManager (or Subversion) is in combination with the Apache 2 web server. This configuration is what I will try to explain in this document. Subversion supports different kinds of authentication methods, but currently SVNManager only supports the per-directory access control method, with the authz_svn_module with an access file.
To get SVNManager up and running, you'll need the following ingredients:
- Windows or Unix operation system
- Apache 2
- Subversion Tools and Apache Modules
- Database (MySQL or SQLite)
- PHP 5 (or better) + Pear (VersionControl_SVN)
- SVNManager package
Generally speaking, if *you* have the choice for an operating system for a repository server, choose what you like best, I don't think one could say that a specific version of Windows / Linux (and probably other flavors of *nix out there) suits better for such an application. All will probably work fine. If you want my advice: Linux is cheap and my favorite flavour is Ubuntu Linux.
Install the Apache 2 webserver from source or with your favorite package manager (preferred).
More information on installing Apache:
- Source: For more information on installing Apache 2.2 from source, see Apache Foundation. Make sure that you add the --enable-so, --enable-dav, --enable-dav-fs and probably --enable-ssl (if you want SSL support) flags.
- Ubuntu: In a terminal window, type: 'sudo apt-get install apache2'
You'll have to install at least the following Subversion Apache 2 modules: 'mod_dav_svn' and 'mod_authz_svn' and command line tools: 'svnadmin' and 'svn'.
More information on installing Subversion:
- Source: For more information on installing Subversion from source, see Getting Subversion. Read the INSTALL file to make sure you fit all dependencies to get the required modules and tools.
- Ubuntu: In a terminal window, type: 'sudo apt-get install subversion libapache2-svn'
- LoadModule dav_svn_module modules/mod_dav_sav.so
- LoadModule authz_svn_module modules/mod_authz_svn.so
This is done by the Ubununtu installation automatically, if not, enable them in a terminal window 'sudo a2enmod dav_svn'.
Afterwards, you'll need to setup Apache to give access to Subversion repository folder. This guide presumes you have scanned the Apache configuration and configured Apache to work for your site. You'll have to add the following section to your Apache configuration. For Ubuntu, this addition should be made in the '/etc/apache2/mods-available/dav_svn.conf' file:
#Repository Folders Location (make sure this folder exists
#and keep location in mind)
AuthName "Restricted Access"
#File will be created by SVNManager, keep location in mind!
#File will be created by SVNManager, keep location in mind
The lines in this configuration starting with '#' are comments and ignored by Apache. You'll have to decide where on the system to put the repositories and config files. These locations must be configured in SVNManager later on. This point is also a good moment to restart Apache, to reload the configuration.
SVNManager is depending on a database backend. The current version of SVNManager is created with Prado (old version) and uses Adodb for database connections. Besides, SVNManager isn't using very exotic SQL statements. Therefore, you might be able to use any SQL database for the storage of the users, repositories and access rights, by specifying the data source name (DSN) in the config. Only, I have tested only the SQLite and the MySQL database.
SQLite is included in PHP 5 and will be installed when you install PHP. MySQL needs to be installed separately:
- Source: For more info on installing MySQL from source, please check MySQL Reference Manual.
- Ubuntu: In a terminal window, type: 'sudo apt-get install mysql-server mysql-client'
The first time you'll start SVNManager, the application checks if a database exists on the specified data source name. If not, SVNManager will try to create a database. Just make sure the database, and possible user and password works and that the specified user (for databases that need authentication) has rights to create tables.
After installation, in a terminal window, run the my mysql client 'sudo mysql -u root -p' and execute the following SQL statements:
CREATE DATABASE svnmanager;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER on svnmanager.* to svnmanager identified by 'secret';
This will create a database named 'svnmanager' and a user 'svnmanager', protected by the password 'secret' (which you should choose for yourself!). This user is granted the rights to create the needed tables.
The advantages of using a MySQL database is scalability and the easier tweaking, with tools like phpMyAdmin.
SVNManager is coded in the PHP 5 programming language, so you'll need an installation of PHP 5, as an Apache 2 module:
- Source: For more info on installing PHP from source see the PHP Manual. Make sure that you enable either '--with-mysql', '--with-mysqli' if you want to use the MySQL database. Also add the '--enable-mbstring' flag to configure support for multibyte character strings. Make sure you make the appropriate changes in your Apache configuration! Installing php from source will also install php-pear.
- Ubuntu: In a terminal window, type: 'sudo apt-get install php5 php5-mysql php5-sqlite php-pear'
After installing PHP, you will have to install a Pear (PHP Extension and Application Repository) module named VersionControl_SVN. You can do this by opening a terminal window and typing: 'sudo pear install -f -o VersionControl_SVN'.
Finally, you will have to download and install the SVNManager package and copy the contents to your web directory (defined in your Apache configuration by the 'DocumentRoot' tag). You'll have to make changes to the config.php configuration file. First make a copy of config.php.linux or config.php.win to start with and open the file in your favorite editor.
Specify the locale settings. You can get a list of available options when you enter 'locale -a' in a terminal window.
$lang = "en_US.UTF-8";
Specify the locations of the needed shell commands: 'htpasswd' or 'htpasswd2', 'svn' and 'svnadmin'. One can locate such files with the command 'whereis', e.g. (in a terminal
window) 'whereis htpasswd'.
$htpassword_cmd = "/usr/bin/htpasswd";
$svn_cmd = "/usr/bin/svn";
$svnadmin_cmd = "/usr/bin/svnadmin";
Specify a Subversion config dir, where the Subversion tools will store configuration data. Next, specify the locations of the repository directory and the config files, as previously configured
in Apache. You have to make these locations manual: 'mkdir /srv/svnconfig /srv/svn/repos'. If you please, you could make empty files for the htpasswd and access file: 'touch /srv/svn/htpasswd /srv/svn/accessfile'.
Important: you must give ownership to these files and directories to the user than runs Apache, e.g. 'www-data', by calling 'chown -R www-data.www-data /srv/svnconfig /srv/svn'.
$svn_config_dir = "/srv/svnconfig";
$svn_repos_loc = "/srv/svn/repos";
$svn_passwd_file = "/srv/svn/htpasswd";
$svn_access_file = "/srv/svn/accessfile";
Although dangerous, SVNManager has the option to delete repositories remotely. To reduce danger and have an extra catch for your users, you can specify a trash folder location. Then,
repositories will not be deleted but moved to the specified location. If you don't specify this, repositories will be removed for ever!
Just as the repository location, you should make this directory yourself: 'mkdir /srv/svn/trash;chown www-data.www-data /srv/svn/trash'.
$svn_trash_loc = "/srv/svn/trash";
Although not specified (and not recommend), SVNManager can also generate svnserve user files. This requires usernames and password to be stored in plain text. If you don't specify this
option, this will not happen. From the moment you configure this option, SVNManager starts storing username and password in plain text, and will generate a svnserver password file at the
Next, you must configure a smpt server. This is necessary for the email-invitation function of SVNManager. SVNManger will send email from 'email@example.com'.
$smtp_server = "smtp-server.net";
Another important configuration option is the Data Source Name of the database that is going to be used with SVNManager. As explained, SVNManager will try to create tables at first startup.
This has been tested with SQLite and MySQL databases. When you specify a SQLite database, it is wise to store it somewhere outside the document root folder, or make sure that Apache can't read
the specified location (e.g. by means of a .htaccess file containing 'deny from all'):
$dsn = "sqlite://svnmanager/svnmanager.db";
Make sure that this location is NOT accessible from the outside (test this)!! This can happen when you choose the example location and Apache is configured to ignore .htaccess files.
An MySQL example, according to the example database, with PHP's mysqli module:
$dsn = "mysqli://svnmanager:secret@localhost/svnmanager";
Because the database starts empty, you'll have to specify an Administrator username and password to begin with. As soon as you have created an admin account in SVNManager, this configured
account will not work anymore.
$admin_name = "admin";
$admin_temp_password = "admin";
For more advanced configurations, it is possible to define a script that will be executed after the creation of a repository. You can use such a script to setup hooks or additional repository
functionality. This script will get the absolute location of the new repository as parameter. When this configuration string is not specified, nothing will happen.
$post_create_script = "newrepo-script";
After configuring, you can start SVNManager by opening the specified location in a web-browser. The first time you'll start SVNManager the database tables will be created. The second time you can login by means of the configured credentials. Please start with creating a safe new administrator account, and re-login into that new account.