What are the steps to setup git-http-backend w/ Apache on Windows?
I would like setup a Git server using the "Smart-HTTP" approach. However, I'm having difficulties getting it to work in Windows, and I'm new to Apache. My httpd.conf, in part:
SetEnv GIT_PROJECT_ROOT "d:/repositories"
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ "C:/Program Files/Git/libexec/git-core/git-http-backend.exe"
<VirtualHost 172.16.0.5:80>
<LocationMatch "^/git/.*/git-receive-pack$">
AuthType Basic
AuthName "Git Access"
Require group committers
</LocationMatch>
</VirtualHost>
Could someone provide the steps to setup a Git server using git-http-backend on Windows?
Solution 1:
There are a few little details to get this working on Windows, but I've managed to do so with the following configuration:
SetEnv GIT_PROJECT_ROOT d:/Export/GIT/
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ "C:/Progra~1/Git/libexec/git-core/git-http-backend.exe/"
<Directory "C:/Program Files/Git/libexec/git-core/">
Options +ExecCGI
Allow From All
</Directory>
I highly recommend watching the apache logs, and event viewer to see what is going wrong.
For example,
-
libiconv.dll
can't be found. In Windows, DLL files need to exist in the$PATH
, or same folder as the.exe
file. Easiest fix, is to copy the file. - In Apache, permissions need to be set to run the executable (
ExecCGI
option).
Now, to continue debugging, here are a few pointers.
The easiest way to monitor the apache logs is by opening the "Git bash" shell, and running the following command:
tail -f /c/Program\ Files/Apache\ Software\ Foundation/Apache2.2/logs/{access,error}.log &
You can enter this command and path using TAB completion, and press 2x TAB to get a list of suggestions. The &
at the end turns it into a background process. Each time you make a request, or restart apache, the new log lines will scroll through your screen.
The tail
process can be stopped by using either:
jobs # See the background jobs
kill %1 # Kill the specific process
or:
fg # Bring the first job in the foreground
Ctrl+C # Kill the foreground process
Don't try to open the git URL in your browser, that won't work. Instead, in the same GIT Bash shell, run the git clone
command. e.g.:
git clone http://localhost/git/somefolder.git
...and you'll see the logs scroll by indicating where things went wrong.
Since the git-http-backend
does not provide any HTML frontend, I can wholeheartedly recommend gitphp for this (note there are multiple projects called almost the same). It's easy to setup, and built with msysGit support in mind too. This should give you a nice web interface to browse all available repositories.
I get problems with spaces in the git folder, these are best to avoid.
Cloning the HTTP url requires at least msysGit 1.7.1 if you like to remember passwords.
The passwords can be stored in a _netrc
file, in your profile folder (%USERPROFILE%
) with the following layout:
machine git.mydomain.com login MyAccount password MyPassword
Alternatively, you can specify the credentials in the clone URL, but this will break submodules.
Footnote: When your server also supports IIS 7 and .NET 4, you may also want to look at http://www.jeremyskinner.co.uk/2010/06/25/hosting-a-git-server-under-iis7-on-windows/ or http://github.com/yysun/Git-Web-Access These projects provide a HTTP-backend for Git, based on .NET. I haven't been able to use these tools, because the server still runs Windows 2003.