Cgit download site

Today I was working on a friends git repository when I noticed that the cgit website is down.  Thankfully I have a backup of the current repository if anyone needs it.

This mirror will auto update if the repository comes back, but will also let you download and install cgit on your own server via the following command.

git clone http://git.mattrude.com/mirror/cgit.git

If you run into any problems with this mirror, please let me know in the comments.

cgit Installed on a Ubuntu Nginx Server

Installing spawn-fcgi

To start out with, we need to install the Nginx and the other dependencies.

apt-get install nginx fcgiwrap git

Ok, here we go, lets start out by creating a place to play with source, I always build in /var/src/ but your welcome to do this anywhere you wish.

/etc/sysconfig/spawn-fcgi:

FCGI_SOCKET=/var/run/fcgiwrap.socket
FCGI_PROGRAM=/usr/local/sbin/fcgiwrap
FCGI_USER=nginx
FCGI_GROUP=nginx
FCGI_EXTRA_OPTIONS="-M 0700"
OPTIONS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET -S $FCGI_EXTRA_OPTIONS -F 1 -P /var/run/spawn-fcgi.pid -- $FCGI_PROGRAM"

Configuring Nginx

server {
    listen 80;
    server_name code.example.com;
    root /var/www/code.example.com;

    fastcgi_param    DOCUMENT_ROOT    /var/www/code.example.com;

    rewrite ^/secure/ https://code.example.com$request_uri permanent;

    location /cgit.css { expires 180d; }
    location /code-logo.png { expires 180d; }
    location /robots.txt { expires 180d; }

    # Serve static files
    location ~* ^.+.(css|png|ico)$ {
        root /var/www/code.example.com;
        expires 30d;
    }

    location / {
        #rewrite ^/([^?/]+/[^?]*)?(?:?(.*))?$ /cgit?url=$1&$2 last;
        include         "fastcgi_params";
        fastcgi_pass    unix:/var/run/spawn-fcgi.socket;
        fastcgi_index   /;
        fastcgi_param   SCRIPT_FILENAME /var/www/code.example.com/cgit.cgi;
        fastcgi_param   PATH_INFO       $uri;
        fastcgi_param   QUERY_STRING    $args;
    }
}

Setting up CGIT to show root directories only

CGIT is a nice, quick, and easy way of displaying git repositories. After much fighting I figured out how to allow CGIT to display URLs such as http://code.example.com/repository.git (the git is optional).

Below is the Apache config for code.example.com:

<VirtualHost *:80>
    ServerName code.example.com
    DocumentRoot /var/www/code.example.com
    CustomLog logs/code.example.com.access_log combined
    ErrorLog logs/code.example.com.error_log
    SetEnv CGIT_CONFIG          /var/www/code.example.com/cgitrc
    Alias /cgit.css             /var/www/code.example.com/cgit.css
    Alias /cgit.png             /var/www/code.example.com/cgit.png
    Alias /favicon.ico          /var/www/code.example.com/favicon.ico
    Alias /robots.txt           /var/www/code.example.com/robots.txt
    Alias /                     /var/www/code.example.com/cgit.cgi/
    <Directory /var/www/code.example.com>
      Options Indexes FollowSymLinks
      Options +ExecCGI
      Order allow,deny
      Allow from all
      AddHandler cgi-script .cgi
      DirectoryIndex cgit.cgi
    </Directory>
</VirtualHost>