aboutsummaryrefslogtreecommitdiff
path: root/content/blog/2023-09-15-self-hosting-gitweb.org
blob: 71f6948e4c21ab343a665251f283716fac3f02d6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#+date: <2023-09-15 Fri 00:00:00>
#+title: Host Your Own Gitweb with Nginx: A Step-by-Step Guide
#+description: Learn how to self-host GitWeb using Nginx, configure fastcgi, and manage git repositories on your server for efficient code browsing.
#+slug: self-hosting-gitweb

* Overview

[[https://git-scm.com/book/en/v2/Git-on-the-Server-GitWeb][GitWeb]] is a
simple web-based visualizer for git repositories. By default, GitWeb
will only run with the =lighttpd= or =webrick= web servers.

However, this guide will show you how to keep GitWeb running in the
background and display information for all repositories in a chosen
directory.

* Install Dependencies

To start, you'll need install the following packages:

#+begin_src sh
sudo apt install git gitweb fcgiwrap nginx
#+end_src

* Configure Nginx

Once installed, create an Nginx configuration file.

#+begin_src sh
sudo nano /etc/nginx/sites-available/git.example.com
#+end_src

#+begin_src conf
server {
        listen 80;
        server_name example.com;

        location /index.cgi {
                root /usr/share/gitweb/;
                include fastcgi_params;
                gzip off;
                fastcgi_param SCRIPT_NAME $uri;
                fastcgi_param GITWEB_CONFIG /etc/gitweb.conf;
                fastcgi_pass  unix:/var/run/fcgiwrap.socket;
        }

        location / {
                root /usr/share/gitweb/;
                index index.cgi;
        }
}
#+end_src

To make the configuration active, you need to symlink it and then
restart Nginx.

#+begin_src sh
sudo ln -s /etc/nginx/sites-available/git.example.com /etc/nginx/sites-enabled/git.example.com
sudo systemctl restart nginx.service
#+end_src

The GitWeb application should now be available via the URL you set in
the Nginx configuration above.

* Customize GitWeb

If you need to, you can customize many things about Gitweb by editing
the [[https://git-scm.com/docs/gitweb.conf][gitweb.conf]] file.

#+begin_src sh
sudo nano /etc/gitweb.conf
#+end_src