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
Best Answer
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.
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.
On
/etc/httpd/conf/httpd.conf
, add this to the VirtualHost for the domain: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:
Create an empty file
/home/domain/public_html/git/reponame.git/git-daemon-export-ok
.Create this as
/home/domain/public_html/git/reponame.git/hooks/post-receive
and make it executable by all, and owned by apache:domain: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):
Update
/home/domain/public_html/git/reponame.git/config
to match the following: