I used VirtualMin's git module to setup a private git over http on one of my servers. I have other servers with git over ssh but this was my first try to setup it over http and with VirtualMin.

Unfortunately, in last few hours I find out that the default VirtualMin's module don't use smart http mode and relay on DAV for pushing commits to the server. Which I don't really like.

Also I tried to move my old repos to this server and I cant use them because there is no /info/ref file. (I also heard that using smart http mode I don't need this file)

In result, I tried to find a document about installing smart git http and found a lot. But I dont think any of them is compatible with VirtualMin or its default git module,

Do any of you people know how I need to customize my git's installation and Apache settings to use smart http protocol with little hurt to VirtualMin and also still be VirtualMin compatible?

I really don't want that my settings and configurations to remove after a VirtualMin update or setting's recreation process that this control panels usually do.

Please share your thoughts on this matter with me. Thanks

OS: CentOs 6.5 x64

  • Why are you so tied to Virtualmin? Virtualmin is a user tool, not something that a sysadmin should be using.
    – EEAA
    May 22, 2014 at 0:48
  • @EEAA No actually. UserMin is a user tool. VirtualMin/WebMin is an admin tool. Of course you can do lot of these things with bare hands yet it makes it more simple for you. I just don't want any incompatibility because I have users who want to add repos using VirtualMin's interface. May 22, 2014 at 21:47

1 Answer 1


Taken from Setting up Smart HTTP for Git on Virtualmin.

From here the solution was to switch from ordinary HTTP to Smart HTTP using the git-http-backend executable, which could execute all the hooks and it supposedly much faster too.

  1. Copy the git-httpd-backend executable to the /home/domain/cgi-bin/directory and set the permissions to domain:domain. This is to avoid suexec problems.

    $ cp /usr/libexec/git-core/git-http-backend /home/domain/cgi-bin
    $ chown domain:domain /home/domain/cgi-bin/git-http-backend
  2. On /etc/httpd/conf/httpd.conf, add this to the VirtualHost for the domain:

    ServerName domain.com
    # Set the root directory where git repositories reside
    SetEnv GIT_PROJECT_ROOT /home/domain/public_html/git
    # By default, the git-http-backend allows push for authenticated
    # users and this directive tells the backend when a user is authenticated.
    # Export all repositories
    ScriptAlias /dev/ /home/domain/cgi-bin/git-http-backend/
    # Add this if it’s not already there
    DAV on
    AuthType Basic
    AuthName domain.com
    AuthUserFile /home/domain/etc/git.basic.passwd
    Require valid-user
    Satisfy All
    RedirectMatch ^/git(/+)$ /git/gitweb.cgi
    RewriteEngine off
    AddHandler cgi-script .cgi
  3. And then restart apache. Now all the repos are now available at http://gituser@domain.com/dev/git/*, e.g., http://gituser@domain.com/dev/git/reponame.git, and all the hooks will execute as expected.

Going forward, when you create a new repo via Virtualmin, you need to do these manual steps:

  1. Create an empty file /home/domain/public_html/git/reponame.git/git-daemon-export-ok.

  2. Create this as /home/domain/public_html/git/reponame.git/hooks/post-receive and make it executable by all, and owned by apache:domain:

    # An example hook script for the "post-receive" event.
    # The "post-receive" script is run after receive-pack has accepted a pack
    # and the repository has been updated. It is passed arguments in through
    # stdin in the form
    # For example:
    # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
    # see contrib/hooks/ for a sample, or uncomment the next line and
    # rename the file to "post-receive".
    # Echo to the client that you’re sending the mail now
    echo "Sending notification email..."
    . /usr/share/git-core/contrib/hooks/post-receive-email
    # Make sure to update the git repo info on the server for pulls by other clients
    git update-server-info
    echo "Updated server info."
  3. As per this link, set the permissions of the git directory as follows so as to avoid a write-permissions problem when pushing new files in commits (while making sure the gitweb.cgi script is only writable by the owner to avoid suexec errors that would appear in /etc/httpd/logs/suexec.log):

    $ cd /home/domain/public_html/git/
    $ chmod -R g+ws *
    $ chgrp -R domain *
    $ chmod -R g-w gitweb.cgi
    $ chmod -R g-s gitweb.cgi
  4. Update /home/domain/public_html/git/reponame.git/config to match the following:

        repositoryformatversion = 0
        filemode = true
        bare = true
       mailinglist = email1@domain.com, email2@domain.com
       envelopesender = git-commits@domain.com
       emailprefix = "[REPONAME] "
  • Feel free to edit the answer as you like, but remember to give credit to the blog post writer as he is the one thtt really helped the OP.
    – mvillar
    Nov 24, 2014 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.