Configure and use a Subversion repository
Create a Subversion repository
Connect to your server via SSH and execute the following commands to create the repositories directory at installdir/repositories and then a new Subversion repository named myapp:
$ sudo mkdir installdir/repositories $ sudo svnadmin create installdir/repositories/myapp $ sudo chown -R bitnami:bitnami installdir/repositories
Configure the Subversion repository URL
If no prefix is set in the Subversion scripts, specify the full path to the repository - for instance, svn://localhost/home/user/repository. In case this is not possible, add the repository path to the Subversion control script.
Edit the file installdir/subversion/scripts/serviceinstall.bat and update the svnserve command line with an additional –root parameter for the repository path. For example:
svnserve.exe -d --listen-port=3690 --root="C:\path\to\repository"
Run the script from an elevated command prompt to apply the changes:
serviceinstall.bat UNINSTALL serviceinstall.bat INSTALL
Linux and Mac OS X
Edit the file installdir/subversion/scripts/ctl.sh and update the svnserve command line with an additional –root parameter for the repository path. For example:
svnserve -d --listen-port=3690 --root=/path/to/repository
Restart the Subversion server.
Browse a Subversion repository using a Web browser
To browse the Subversion repository using a Web browser, follow the steps below:
Update the Apache configuration file at installdir/apache2/conf/httpd.conf to load the following modules:
Update the Apache configuration file at /opt/bitnami/apache2/conf/httpd.conf to load the following modules:
LoadModule dav_module modules/mod_dav.so LoadModule dav_fs_module modules/mod_dav_fs.so LoadModule dav_svn_module modules/mod_dav_svn.so LoadModule authz_svn_module modules/mod_authz_svn.so
Update the Apache configuration for Subversion. Depending on your installation type, follow these steps:
Approach A (Bitnami installations using system packages): Edit the installdir/apache2/conf/vhosts/subversion-vhost.conf file and add the following lines. The directives below will let you view the default repository at installdir/repository by browsing to http://localhost/.
<VirtualHost 127.0.0.1:80 _default_:80> ServerAlias * <Location /> DAV svn SVNPath "/opt/bitnami/repository" </Location> </VirtualHost>
Approach B (Self-contained Bitnami installations): In the same httpd.conf file, verify the endpoint URL and path for your Subversion repository. For example, the directives below will let you view the default repository at installdir/repository by browsing to http://localhost/subversion/.
<Location /subversion> DAV svn SVNPath "installdir/repository" </Location>
$ sudo installdir/ctlscript.sh restart apache
You should now be able to checkout the repository using a tool like TortoiseSVN. Simply enter the URL as http://SERVER-IP/repository as the repository checkout URL in the TortoiseSVN interface, as shown below.
Enable access over HTTPS
You can also access the repository over HTTPS if you have configured the Apache SSL certificate for your server. The following error can occur if the hostname reported by the server does not match the hostname in the SSL certificate. Make sure your server configuration uses the correct ServerName value.
svn: OPTIONS of 'https://example.com/repository': SSL negotiation failed: SSL error code -1/1/336032856 (https://example.com)
Enable commits over HTTP(S)
For security reasons, the default configuration does not allow users to commit changes to the repositories over HTTP or HTTPS. To permit this, change the permissions of your repository directory so that the Apache user is able to write to it.
Run the following command, assuming your repository is located at the default location of installdir/repository:
$ sudo chown -R daemon:subversion installdir/repository
IMPORTANT: Making this change will allow any user to commit changes to your repository. To avoid unauthorized commits and possible data loss, configure basic authentication for your repository as discussed in the next section
You should now be able to commit changes to the repository using a tool like TortoiseSVN, as shown below.
Configure basic authentication for a Subversion repository
Once your repository is accessible over HTTP(s), it is recommended that you protect it from unauthorized access by configuring authentication for different users. To do this, follow the steps below:
Update the Apache configuration to enable basic authentication. Depending on your installation type, follow these steps:
Approach A (Bitnami installations using system packages): Update the Apache configuration file at installdir/apache2/conf/vhosts/subversion-vhost.conf and add the highlighted directives below.
<Location /> DAV svn SVNPath "installdir/repository" AuthType Basic AuthName "Subversion repository" AuthUserFile installdir/repository/users require valid-user </Location>
Approach B (Self-contained Bitnami installations): Update the Apache configuration file at installdir/apache2/conf/httpd.conf and add the highlighted directives below.
<Location /subversion> DAV svn SVNPath "installdir/repository" AuthType Basic AuthName "Subversion repository" AuthUserFile installdir/repository/users require valid-user </Location>
With this configuration, repository access is only available to those users listed in the installdir/repository/users file and they will need to authenticate themselves before gaining access. Note that you should update the path to the file based on the actual location of your repository.
Create the installdir/repository/users file and add a user account named myuser to it using the following command. You will be prompted to enter a password for the user account. Note that you should update the path to the file based on the actual location of your repository.
$ sudo installdir/apache2/bin/htpasswd -c installdir/repository/users myuser
Repeat this step to add more users, omitting the -c argument on subsequent invocations. For example:
$ sudo installdir/apache2/bin/htpasswd installdir/repository/users myotheruser
Restart the Apache server.
$ sudo installdir/ctlscript.sh restart apache
If you now attempt to browse to the repository or access it using TortoiseSVN, you will be prompted for a user name and password, as shown below:
Enable anonymous browsing
If you want your repository readable but not editable by any other user, perform the steps above but changing the line
<LimitExcept GET PROPFIND OPTIONS REPORT> require valid-user </LimitExcept>
Enable HTTPS access only
If you only want to only allow access through HTTPS, not HTTP, you should add SSLRequireSSL to the directives described above:
... AuthName "Subversion repository" AuthUserFile installdir/repository/users require valid-user SSLRequireSSL </Location>
Enable Subversion post-commit notifications
To configure a Subversion repository to send emails via SMTP with the commit log, follow these steps:
Download the latest source code from Subversion and copy the hooks directory into the installdir/subversion directory:
$ wget http://apache.mesi.com.ar/subversion/subversion-1.8.9.tar.gz $ tar -xzvf subversion-1.8.9.tar.gz $ sudo cp -r subversion-1.8.9/tools/hook-scripts installdir/subversion/hooks
Copy the example mailer.conf file:
$ sudo cp installdir/subversion/hooks/mailer/mailer.conf.example installdir/subversion/hooks/mailer/mailer.conf
Configure the SMTP mail settings in the mailer.conf file. Here is an example for a Gmail account:
[General] smtp_hostname = smtp.gmail.com:465 smtp_username = your_gmail_account smtp_password = your_password smtp_use_ssl = true ... [defaults] from_addr = firstname.lastname@example.org # The default To: addresses for message. One or more addresses, # separated by whitespace (no commas). # NOTE: If you want to use a different character for separating the # addresses put it in front of the addresses included in square # brackets '[ ]'. to_addr = email@example.com # If this is set, then a Reply-To: will be inserted into the message. reply_to = firstname.lastname@example.org
Configure your post-commit hook script to use the mailer.py and mailer.conf files. The location of your post-commit script depends on the location of your repository. Edit the installdir/repositories/REPOSITORY-NAME/hooks/post-commit.tmpl file and replace the last line with the following one:
installdir/python/bin/python installdir/subversion/hooks/mailer/mailer.py commit "$REPOS" "$REV" installdir/subversion/hooks/mailer/mailer.conf
In case the installdir/python directory does not exist, use the system’s Python binary, usually at /usr/bin/python.
Enable the post-commit hook by renaming the post-commit script and removing the .tmpl extension:
$ sudo mv installdir/repositories/your_repo/hooks/post-commit.tmpl installdir/repositories/your_repo/hooks/post-commit
To test it, change a file and commit the changes. In case of an error, the error message will be displayed after the commit.