Tag: debian

Install private Git server under Apache and Debian

This guide lists all the step you need to take to install a git server which is accessible via http. If you have no need for https you can skip this part in the tutorial. After following all the steps it did not work immediately, I did have to tweak the apache configuration a little and install additional packages, the end result can be found below.

The git-core package was also installed using apt-get install git-core.

This VirtualHost configuration also limits access to only IP addresses in the subnet 192.168.*.* and requires a password, stored in the htpasswd file located at /var/www/git.example.com/git.passwd

Pay special attention to this line: ScriptAlias /git/ /usr/lib/git-core/git-http-backend/ and verify that the location of the git-core directory is correct. On some installations the path might be /usr/libexec/git-core/git-http-backend or something similar.

<VirtualHost>
    ServerAdmin webmaster@localhost
    ServerName git.example.com
    DocumentRoot /var/www/git.example.com/htdocs
<Directory>
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    SetEnv GIT\_PROJECT\_ROOT /var/git/repository
    SetEnv GIT\_HTTP\_EXPORT\_ALL
    SetEnv REMOTE\_USER=$REDIRECT\_REMOTE\_USER
    ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
    <Location>
        Deny from all
        Allow from 127.0.0.1
        Allow from 192.168
    </Location>
    <Location /git>
        AuthType Basic
        AuthName "Git Repository"
        AuthUserFile /var/www/git.example.com/git.passwd
        Require valid-user
    </Location>

    ErrorLog ${APACHE\_LOG\_DIR}/error.log
    # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
    LogLevel warn
    CustomLog ${APACHE\_LOG\_DIR}/access.log combined
</VirtualHost>

Read the next git blog post to learn how to also browse the git repositories using your webbrowser.

Create new git repository

To create a new git repository execute:

git init <span class="hljs-comment">--bare name_of_project.git</span>

On a remote machine you can checkout this project by executing:

git <span class="hljs-keyword">clone</span> <span class="hljs-title">http</span>://git.example.com/git/name_of_project.git

On the first push command to send the changes to the server, you need to specify that you were working on the master. The original repository was bare, so git does not know that yet. The command below takes care of that:

git <span class="hljs-built_in">push</span> <span class="hljs-built_in">origin</span> master

Leave a Comment

Install SVN server under Apache on Debian

A very good and readable howto is available at http://www.howtoforge.com/debian_subversion_websvn. I have made some additional changes after following this guide. The guide requires you to manually add each repository manually to the dav_svn.conf file. It is possible to do this differently, in a VirtualHost configuration. Do not enable the lines in dav_svn.conf but add the following lines to your desired VirtualHost configuration, in this example with ServerName svn.example.com:

<Location>
    Deny from all
    Allow from 192.168
</Location>
<Location /svn>
    DAV svn
    SVNParentPath /var/svn/repository/
    SVNListParentPath on
    AuthType Basic
    AuthName "Subversion Repository"
    AuthUserFile /var/www/svn.example.com/dav_svn.passwd
    Require valid-user
</Location>

In this configuration there are the following things to keep in mind:

  • The parent folder of my SVN repository is different than the mentioned guide, /var/svn-repos is changed to /var/svn/repository
  • Access to this repository is restricted to only a specific subnet (192.168.*.* which is my own local network) by the first Location directive
  • All repositories are accessible via _http://svn.example.com/svn/\[name of repository] . _The usernames and passwords are configured in the dav_svn.passwd file, generated with htpasswd -c _/var/www/svn.example.com/dav_svn.passwd _(do not forget to create the folder in /var/www).

Leave a Comment