cmc/cleberg.net

My personal web garden & blog.

clone: git clone https://gitbay.org/cmc/cleberg.net.git

main: content/blog/2023-09-15-self-hosting-gitweb.org · raw

 1#+date:        [2023-09-15 Fri 00:00:00]
 2#+title:       Self-Hosting Guide: GitWeb
 3#+description: Deploying GitWeb on Linux with Nginx and FastCGI.
 4#+slug:        self-hosting-gitweb
 5#+filetags:    :linux:self-hosting:
 6
 7* Overview
 8
 9[[https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb][GitWeb]] is a
10simple web-based visualizer for git repositories. By default, GitWeb
11will only run with the =lighttpd= or =webrick= web servers.
12
13However, this guide will show you how to keep GitWeb running in the
14background and display information for all repositories in a chosen
15directory.
16
17* Install Dependencies
18
19To start, you'll need install the following packages:
20
21#+begin_src sh
22sudo apt install git gitweb fcgiwrap nginx
23#+end_src
24
25* Configure Nginx
26
27Once installed, create an Nginx configuration file.
28
29#+begin_src sh
30sudo nano /etc/nginx/sites-available/git.example.com
31#+end_src
32
33#+begin_src conf
34server {
35        listen 80;
36        server_name example.com;
37
38        location /index.cgi {
39                root /usr/share/gitweb/;
40                include fastcgi_params;
41                gzip off;
42                fastcgi_param SCRIPT_NAME $uri;
43                fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
44                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
45        }
46
47        location / {
48                root /usr/share/gitweb/;
49                index index.cgi;
50        }
51}
52#+end_src
53
54To make the configuration active, you need to symlink it and then
55restart Nginx.
56
57#+begin_src sh
58sudo ln -s /etc/nginx/sites-available/git.example.com /etc/nginx/sites-enabled/git.example.com
59sudo systemctl restart nginx.service
60#+end_src
61
62The GitWeb application should now be available via the URL you set in
63the Nginx configuration above.
64
65* Customize GitWeb
66
67If you need to, you can customize many things about Gitweb by editing
68the [[https://git-scm.com/docs/gitweb.conf][gitweb.conf]] file.
69
70#+begin_src sh
71sudo nano /etc/gitweb.conf
72#+end_src