Self-hosting a lightweight Git web interface like CGIT written in C provides near-instant page loads, minimal RAM footprint, and syntax-highlighted code browsing compared to heavyweight alternatives like GitLab.
Stack: CentOS 7 • CGIT • fcgiwrap • Nginx • highlight syntax engine
1. Installing Prerequisites and fcgiwrap
CGIT operates as a FastCGI binary. Install fcgiwrap to interface between Nginx and the CGIT binary:
yum install epel-release -y
yum install fcgi-devel highlight git autoconf automake libtool -y
cd /usr/src
git clone https://github.com/gnosek/fcgiwrap.git
cd fcgiwrap
autoreconf -i
./configure --prefix=/usr
make && make install
2. Compiling CGIT from Source
cd /usr/src
git clone https://git.zx2c4.com/cgit
cd cgit
git submodule init
git submodule update
make get-git
make && make install
3. Nginx FastCGI Integration
Configure Nginx to route CGIT requests to the fcgiwrap socket:
location / {
fastcgi_pass unix:/var/run/fcgiwrap.sock;
fastcgi_param SCRIPT_FILENAME /var/www/htdocs/cgit/cgit.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_STRING $args;
fastcgi_param HTTP_HOST $server_name;
include fastcgi_params;
}