The most basic Git configuration allows anonymous read access to the Git repository using the git-http-backend script provided with Git versions 1.6.6 and greater.
The only thing to do is modify the Apache configuration to use the git-http-backend script. Ensure mod_cgi, mod_alias, and mod_env are enabled, set GIT_PROJECT_ROOT (or DocumentRoot) appropriately, and create a ScriptAlias to the CGI. The GIT_PROJECT_ROOT should point to the root folder where git repositories would be hosted.
<VirtualHost 10.20.30.40:80> DocumentRoot /var/www/git ServerName git.example.com <Directory "/var/www/git"> Allow from All Options +ExecCGI AllowOverride All </Directory> SetEnv GIT_HTTP_EXPORT_ALL SetEnv GIT_PROJECT_ROOT /var/www/git ScriptAlias /git /usr/lib/git-core/git-http-backend </VirtualHost> |
At this point an anonymous user should be able to clone the project repository by issuing the following command:
git clone http://www.example.com/git/projects/example |
Note: Users are not yet able to push changes back to the repository.
Note: Adding the SuExec directive in the base configuration will cause the git-http-backend script to cease functioning correctly.