[[!meta title="Serving Git on Gentoo"]] Today I decided to host all my public [[Git]] repositories on my [[Gentoo]] server. Here's a quick summary of what I did. Gitweb ====== Re-emerge `git` with the `cgi` USE flag enabled. # echo "dev-util/git cgi" >> /etc/portage/package.use/webserver # emerge -av git Create a virtual host for running `gitweb`: # cat > /etc/apache2/vhosts.d/20_git.example.net_vhost.conf << EOF ServerName git.example.net DocumentRoot /usr/share/gitweb Allow from all AllowOverride all Order allow,deny Options ExecCGI SetHandler cgi-script DirectoryIndex gitweb.cgi SetEnv GITWEB_CONFIG /etc/gitweb.conf EOF Tell `gitweb` where you keep your repos: # echo "\$projectroot = '/var/git';" > /etc/gitweb.conf Tell `gitweb` where people can pull your repos from: # echo "@git_base_url_list = ( 'git://example.net', ); >> /etc/gitweb.conf Restart Apache: # /etc/init.d/apache2 restart Add the virtual host to your DNS server. # emacs /etc/bind/pri/example.net.internal ... git A 192.168.0.2 ... Restart the DNS server. # /etc/init.d/named restart If names aren't showing up in the `Owner` column, you can add them to the user's `/etc/passwd` comment with # usermod -c 'John Doe' jdoe Thanks to Phil Sergi for his own [summary][], which I've borrowed from heavily. Git daemon ========== Gitweb allows browsing repositories via HTTP, but if you will be pulling from your repositories using the `git://` protocol, you'll also want to run `git-daemon`. On Gentoo, this is really easy, just edit `/etc/conf.d/git-daemon` as you see fit. I added `--verbose`, `--base-path=/var/git` and `--export-all` to `GITDAEMON_OPTS`. Start the daemon with # /etc/init.d/git-daemon start Add it to your default runlevel with # rc-update add git-daemon default If you're logging to syslog and running syslog-ng, you can configure the log location using the usual syslog tricks. See my [[syslog-ng]] for details. [summary]: http://www.philsergi.com/2008/04/gitweb-apache-gentoo.html [[!tag tags/git]] [[!tag tags/linux]] [[!tag tags/tools]] [[!tag tags/web]]