Skip to content
Search

Svn:ApacheHttpd

lastmod 2025-02-14created 2014-04-2919 edits

Describes how to integrate accounts so that Subversion can be connected through Apache httpd.

Module

The modules required for SVN integration are as follows. (They can be added only after the mod_dav.so module is loaded.)

<IfModule dav_module>
LoadModule dav_svn_module "[SVN_ROOT]/bin/mod_dav_svn.so"
LoadModule authz_svn_module "[SVN_ROOT]/bin/mod_authz_svn.so"
</IfModule>

Getting Subversion under MacPorts

Install mod_dav_svn using macports.

$ sudo port install subversion +mod_dav_svn

If an update is needed, proceed as follows.

$ sudo port selfupdate

How to install

Installation steps based on CentOS7.

First, install the related modules.

$ yum install httpd subversion mod_dav_svn

Then create the Svn:Authz file manually, and create the htpasswd file.

$ mkdir /etc/httpd/auth
$ cd /etc/httpd/auth
$ vi authz
$ htpasswd -cs htpasswd.ht lcw

Write the httpd configuration file referring to the content below. The simplest way is to edit the bottom of the /etc/httpd/conf.modules.d/10-subversion.conf file.

Open the firewall.

$ firewall-cmd --permanent --zone=public --add-service=http
$ firewall-cmd --permanent --zone=public --add-service=https
$ firewall-cmd --reload

Create the repository, then change its owner to the Apache user.

$ mkdir /var/www/svn
$ cd /var/www/svn/
$ svnadmin create repo
$ chown -R apache.apache repo/

Change the selinux context.

$ chcon -R -t httpd_sys_content_t /var/www/svn/repo
$ chcon -R -t httpd_sys_rw_content_t /var/www/svn/repo

Finally, restart httpd.

$ systemctl enable httpd.service
$ systemctl restart httpd.service
## OR:
$ apachectl restart

Integrating with Apache httpd

Connect to SVN as follows.

  • To connect multiple repositories: SVNParentPath "[SVN_REPO_PARENT_PATH]"
  • To connect a single repository: SVNPath "[SVN_REPO_PATH]"
<Location /svn>
DAV svn
SVNParentPath "[SVN_REPO_PARENT_PATH]"
</Location>

Integrating with htaccess

After integrating htaccess, connect svn's authz file. Use AuthzSVNAccessFile for this.

AuthType Basic
AuthName "[AUTH_NAME]"
AuthUserFile "[HTPASSWD_PATH]"
Require valid-user

AuthzSVNAccessFile "[AUTHZ_PATH]"

SVNParentPath

Enter the parent path that holds the SVN repositories. Note that you must not add "/" at the end of the path.

Example:

SVNParentPath "/repo/svn"

SVN + HTPASSWD

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
LoadModule dontdothat_module  modules/mod_dontdothat.so

<Location /svn>
    DAV svn
    SVNParentPath "/repo/svn"

    # Authentication
    AuthType Basic
    Require valid-user
    AuthName "My subversion repository"

    AuthUserFile "/etc/httpd/auth/htpasswd.ht"
    AuthzSVNAccessFile "/etc/httpd/auth/authz"
</Location>

Integrating Apache httpd + SSL + LDAP

<IfModule dav_svn_module>
<IfModule authz_svn_module>
<IfModule ssl_module>

<VirtualHost *:8002>
    SSLEngine               on
    SSLCertificateFile      "conf/openssl/pnd_admin.crt"
    SSLCertificateKeyFile   "conf/openssl/pnd_admin.key"
    SSLProtocol             all
    SSLCipherSuite          HIGH:MEDIUM

    <Location /svn/roadie2>
        Order   Deny,Allow
        Allow   from all

        DAV svn
#       SVNParentPath   "D:/PND_Team/repository/"
        SVNPath         "D:/PND_Team/repository/roadie2/"

        # ldap authentication
        AuthType                Basic
        AuthName                "SVN Repository"
        AuthBasicProvider       ldap
        AuthLDAPURL             "ldap://localhost:8102/dc=pnd,dc=geosoft?uid"
        AuthzLDAPAuthoritative  on

        AuthLDAPGroupAttribute      uniqueMember
        AuthLDAPGroupAttributeIsDN  on
        Require ldap-group cn=roadie2,cn=svn,dc=pnd,dc=geosoft
    </Location>
</VirtualHost>

</IfModule>
</IfModule>
</IfModule>

Troubleshooring

500 Internal server error

In this case, checking the error log is the fastest way. In my experience, this is usually most likely caused by the htpasswd file not being readable.

See also

Favorite site

author Zer0 sitemap