Fix gci -> cgi typo in gitweb post.
[blog.git] / posts / gitweb.mdwn
1 [[!meta  title="Serving Git on Gentoo"]]
2
3 Today I decided to host all my public [[Git]] repositories on my
4 [[Gentoo]] server.  Here's a quick summary of what I did.
5
6 Gitweb
7 ======
8
9 Re-emerge `git` with the `cgi` USE flag enabled.
10
11     # echo "dev-util/git cgi" >> /etc/portage/package.use/webserver
12     # emerge -av git
13
14 Create a virtual host for running `gitweb`:
15
16     # cat > /etc/apache2/vhosts.d/20_git.example.net_vhost.conf << EOF
17     <VirtualHost *:80>
18         ServerName git.example.net
19         DocumentRoot /usr/share/gitweb
20         <Directory /usr/share/gitweb>
21             Allow from all
22             AllowOverride all
23             Order allow,deny
24             Options ExecCGI
25             <Files gitweb.cgi>
26                 SetHandler cgi-script
27             </Files>
28         </Directory>
29         DirectoryIndex gitweb.cgi
30         SetEnv  GITWEB_CONFIG  /etc/gitweb.conf
31     </VirtualHost>
32     EOF
33
34 Tell `gitweb` where you keep your repos:
35
36     # echo "\$projectroot = '/var/git';" > /etc/gitweb.conf
37
38 Tell `gitweb` where people can pull your repos from:
39
40     # echo "@git_base_url_list = ( 'git://example.net', ); >> /etc/gitweb.conf
41
42 Restart Apache:
43
44     # /etc/init.d/apache2 restart
45
46 Add the virtual host to your DNS server.
47
48     # emacs /etc/bind/pri/example.net.internal
49     ...
50     git  A  192.168.0.2
51     ...
52
53 Restart the DNS server.
54
55     # /etc/init.d/named restart
56
57 If names aren't showing up in the `Owner` column, you can add them to
58 the user's `/etc/passwd` comment with
59
60     # usermod -c 'John Doe' jdoe
61
62 Thanks to Phil Sergi for his own [summary][], which I've borrowed from
63 heavily.
64
65 Git daemon
66 ==========
67
68 Gitweb allows browsing repositories via HTTP, but if you will be
69 pulling from your repositories using the `git://` protocol, you'll
70 also want to run `git-daemon`.  On Gentoo, this is really easy, just
71 edit `/etc/conf.d/git-daemon` as you see fit.  I added `--verbose`,
72 `--base-path=/var/git` and `--export-all` to `GITDAEMON_OPTS`.  Start
73 the daemon with
74
75     # /etc/init.d/git-daemon start
76
77 Add it to your default runlevel with
78
79     # rc-update add git-daemon default
80
81 If you're logging to syslog and running syslog-ng, you can configure
82 the log location using the usual syslog tricks.  See my [[syslog-ng]]
83 for details.
84
85 [summary]: http://www.philsergi.com/2008/04/gitweb-apache-gentoo.html
86
87 [[!tag tags/git]]
88 [[!tag tags/linux]]
89 [[!tag tags/tools]]
90 [[!tag tags/web]]