Fork me on GitHub

Setting up Gitosis and Gitweb with nginx

I have recently migrated to a self-hosted plan to host my blog and any other things I want to do. At first, I was using the apache web server, but finally I decided that this software was using too much memory for what it's doing. Considering the limited hardware I'm having, my choice ported to nginx. Well, obviously, nginx doesn't support as much features than apache. You're forced to use php and anything that create dynamic content with fastcgi. Heh, big deal. So, back on the topic: gitosis and gitweb. I'm sure you'll find profusion of howto on the web about theses topics. I'm not here to write yet another tutorial on the subject. However, and here is the little tricky part, how to serve the gitweb cgi with nginx ? Well, first I use fcgiwrap and spawn-cgi, and if you're using debian, you'd better to get the latest sources of fcgiwrap. Quite simple to install and configure. Gitosis is installed in /srv/gitosis, with its default gitweb.conf. So now all we have to do is to configure nginx to make thinks works. That quite simple: here is a sample of my config.

server {
        listen 80;
        server_name example.com;
        location / {
                # Anything unrelated to gitweb
        }
        location /gitweb/index.cgi {
                root /usr/share/;
                include fastcgi_params;
                gzip off;
                fastcgi_param SCRIPT_NAME $uri;
                fastcgi_param GITWEB_CONFIG /srv/gitosis/gitweb.conf;
                fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }
        location /gitweb/ {
                root /usr/share/;
                index index.cgi;
        }
}

Simple enough, right ?

blogroll

social