This guide walks through a self-hosted installation of cgit.
Install required packages including Git and build tools.
sudo apt-get update && sudo apt-get install -y git build-essential liblua5.3-dev
Download the cgit source code from the official repository.
git clone https://git.zx2c4.com/cgit/ /opt/cgit-src
cd /opt/cgit-src
Compile cgit from source.
make prefix=/usr
sudo make install
<VirtualHost *:80>
ServerName git.example.com
DocumentRoot /var/www/cgit
<Directory "/var/www/cgit">
Options +ExecCGI
AddHandler cgi-script .cgi
DirectoryIndex cgit.cgi
</Directory>
</VirtualHost>
server {
listen 80;
server_name git.example.com;
location / {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/cgit/cgit.cgi;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
}
Create the cgit configuration file at /etc/cgitrc:
virtual-root=/
cache-root=/var/cache/cgit
scan-path=/srv/git/public
enable-http-clone=1
remove-suffix=1
strict-export=1
Prefer automation? See cgit Ansible Setup for an example playbook.
Note: cgit does not have an official Docker image. As a lightweight C-based CGI application, cgit is typically installed directly on the host system. Community Docker images exist but are not officially supported. See cgit Docker Setup for community options.
Any questions?
Feel free to contact us. Find all contact information on our contact page.