November 16, 2025

Part 2: set up a cgit instance on a remote server running git

See part 1: https://yctct.com/cgit-instance-setup-1

Note: I am making these notes a few months after I started to set up my own cgit instance. There might be some omissions, or mistakes. Feel free to email me if you have questions.

Install cgit from the repository of your distribution

Surprisingly most blog posts cover an install from source; you probably don’t need to do so.

On the distribution I use, GNU/Linux Trisquel, the command to install cgit is:

# apt upgrade
# apt update
# apt install cgit
# apt install fcgiwrap 

cgit requires fcgiwrap.

Add the website git.example.com to an Nginx instance

Follow the steps from: https://yctct.com/add-website

Write cgit config file

In /etc/nginx/sites-available/cgit.conf, I now have:

135 location @cgit {
136   fastcgi_param   SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
137   fastcgi_split_path_info   ^(/git/?)(.+)$;
138   fastcgi_param   PATH_INFO       $uri;
139   #fastcgi_param   PATH_INFO       $fastcgi_path_info;
140   fastcgi_param   QUERY_STRING    $args;
141   fastcgi_param   HTTP_HOST       $server_name;
142   fastcgi_pass    unix:/run/fcgiwrap.socket;
143     }

Also, adjust paths to certificates and customise URLs.

I can send you more bits of my configuration file if you’d like.

You might need to reload Nginx’s config.

# systemctl restart fcgiwrap
# systemctl restart nginx

You can test if config is set up properly with:

# ngnix -t

As I am putting this post together, the file /etc/cgitrc on my server looks like:

# cgit config
# see cgitrc(5) for details

#css=/cgit-css/cgit.css
#logo=/cgit-css/cgit.png

# prepend this string to every url
# 3 line below uncommented on 04.11.2025 to test
virtual-root=/
enable-index-links=1
enable-commit-graph=1

# I got the few lines below from
# https://landchad.net/cgit/
css=/cgit.css
# logo=/cgit.svg
#virtual-root=/
clone-prefix=https://git.yctct.com

# Title and description shown on top of each page
root-title=yctct's repositories
root-desc=deployed using cgit

enable-git-config=1
# list of repositories to be displayed in cgit
#project-list=/home/git/projects.list
# The location where git repos are stored on the server
# scan-path will duplicate repository on cgit pages
#scan-path=/home/git/repositories

repo.url=wcm
repo.owner=yctct
repo.path=/home/git/repositories/wcm.git
repo.desc= a script to count words in Markdown files
# follow the syntax of 4 lines above for other repository

Final note

As mentioned earlier, these are notes I took months after I set up my cgit instance.

There are probably omissions.

Feel free to send me an email if you are trying to set up your cgit instance and have questions.

Next post: how to add a repository to your cgit instance https://yctct.com/cgit-add-repository


personal computing command-line interface (cli) gnu linux trisquel shell literacy wiki cgit git hosting

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2025 by yctct is licensed under CC BY-SA 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88