apt update
apt install cgit
dpkg --status cgit
# install Recommends
apt install apache2 python3-docutils python3-markdown python3-pygments
cd /etc/apache2/conf-enabled
ln -s ../conf-available/cgit.conf git.conf
cd /etc/apache2/mods-enabled
ln -s ../mods-available/cgi.load cgi.load
systemctl restart apache2
# cp -r /usr/share/git-core/templates ~/git-template
# cd ~/git-template
# git config --local gitweb.owner 'Test User'
# git config --local gitweb.url 'https://example.com/'
# echo "default description" > description
# git config --global init.templateDir /home/remoteuser/git-template
mkdir /srv/git-repos/
cd /srv/git-repos/
git init --bare hello.git
cd hello.git
echo "Example repository" > description
git config --local gitweb.owner 'Test User'
git config --local gitweb.url 'https://example.com/'
cat >/etc/cgitrc <<EOF
#
# cgit config
# see cgitrc(5) for details
css=/cgit-css/cgit.css
logo=/cgit-css/cgit.png
virtual-root=/cgit/
root-title=example.com git repositories
root-desc=tracking the foobar development
root-readme=/var/www/htdocs/about.html
clone-url=http://$HTTP_HOST$SCRIPT_NAME/$CGIT_REPO_URL ssh://root@$HTTP_HOST:/srv/git-repos/$CGIT_REPO_URL
#clone-prefix=http://foo.org/
enable-index-owner=1
enable-http-clone=1
enable-index-links=1
enable-git-config=1
enable-blame=1
enable-commit-graph=1
enable-log-filecount=1
enable-log-linecount=1
branch-sort=age
max-stats=quarter
snapshots=tar.gz tar.bz2 zip
mimetype.gif=image/gif
mimetype.html=text/html
mimetype.jpg=image/jpeg
mimetype.jpeg=image/jpeg
mimetype.pdf=application/pdf
mimetype.png=image/png
mimetype.svg=image/svg+xml
# source-filter 要放在scan-path之前才会生效
source-filter=/usr/lib/cgit/filters/syntax-highlighting.py
about-filter=/usr/lib/cgit/filters/about-formatting.sh
readme=:README.md
readme=:readme.md
readme=:README.mkd
readme=:readme.mkd
readme=:README.rst
readme=:readme.rst
readme=:README.html
readme=:readme.html
readme=:README.htm
readme=:readme.htm
readme=:README.txt
readme=:readme.txt
readme=:README
readme=:readme
readme=:INSTALL.md
readme=:install.md
readme=:INSTALL.mkd
readme=:install.mkd
readme=:INSTALL.rst
readme=:install.rst
readme=:INSTALL.html
readme=:install.html
readme=:INSTALL.htm
readme=:install.htm
readme=:INSTALL.txt
readme=:install.txt
readme=:INSTALL
readme=:install
# scan-path 和 仓库要放在最后
scan-path=/srv/git-repos/
EOF
# web访问http://ip/cgit