Install cGit in nginx subfolder

Originally from nginx + cgit in a subfolder

Install cGit

  1. Get the code

    git clone http://git.zx2c4.com/cgit

  2. Submodule init & update

  3. Build

    make

  4. Copy
    • cgit -> cgit.cgi
    • cgit{.css,.png}
    • filters

Configure Cgit

#
# cgit config
#

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

scan-path=/home/git/repos

# Following lines work with the above Apache config
#css=/cgit-css/cgit.css
#logo=/cgit-css/cgit.png

# Following lines work with the above Lighttpd config
css=/cgit/cgit.css
logo=/cgit/cgit.png

# if you don't want that webcrawler (like google) index your site
robots=noindex, nofollow

# if cgit messes up links, use a virtual-root. For example has cgit.example.org/ this value:
virtual-root=/git/

enable-http-clone=1

root-title=Tuowen's Personal Git Repositories

root-desc=Personal trash bin (:-)rz

enable-index-owner=0

Configure nginx

  location /cgit/ {
    alias /home/git/cgit/;
    index index.html index.htm;
  }

  location /git/ {
    alias /home/git/repos/;
    fastcgi_param SCRIPT_FILENAME /home/git/cgit/cgit.cgi;
    fastcgi_pass unix:/var/run/fcgiwrap.socket;
    fastcgi_split_path_info           ^(/git/?)(.+)$;
    fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param QUERY_STRING $args;
  }