andrewcodispoti.com

install cgit on DreamHost by Andrew Codispoti (support my work)
Published: Wed, Nov 3, 2021; Updated: Mon, Mar 14, 2022
Reading time: 1 minute(s) (200 words)
License: CC BY-SA 4.0 (details)

cgit

To install cgit on Dreamhost shared server:

$ git clone https://git.zx2c4.com/cgit
$ cd cgit
$ git submodule init
$ git submodule update
$ $EDITOR cgit.conf

Edit first two lines to match your Dreamhost setup:

# cgit.conf
homedir = /home/youruser/
CGIT_SCRIPT_PATH = $(homedir)/cgit.yourdomain.com
CGIT_CONFIG = $(homedir)/.cgitrc
CGIT_DATA_PATH = $(CGIT_SCRIPT_PATH)
CACHE_ROOT = $(homedir)/var/cache/cgit
prefix = $(homedir)/.local
libdir = $(prefix)/lib
filterdir = $(libdir)/cgit/filters
docdir = $(prefix)/share/doc/cgit
htmldir = $(docdir)
pdfdir = $(docdir)
mandir = $(prefix)/share/man

Save the file, then:

$ make NO_LUA=1
$ make install

Write config file:

$ $EDITOR $HOME/.cgitrc

Here’s a bare minimum content (see cgitrc.5.txt for details):

# .cgitrc
repo.url=foo
repo.path=/home/youruser/git/foo.git
repo.desc=the master foo repository
repo.owner=fooman@yourdomain.com
repo.readme=info/web/about.html

If you’re using subdomain or the root of your web (not a subdirectory), you may want to edit an .htaccess in your web root:

# .htaccess
DirectoryIndex cgit.cgi
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /cgit.cgi/$1 [END,QSA]
RewriteCond %{QUERY_STRING} service=git-receive-pack
RewriteRule .* - [END,F]

Additional resources: