Debian. Installing and Configuring Gitweb + Nginx
Continuing the discussion of tools for git repositories, today I’ll talk about GitWeb. It’s a simple web frontend for browsing Git repositories, where you can view your projects, history, and so on—in short, everything you need.
Mercurial users will already be familiar with its appearance, since hgweb provided it:
[web] # стиль gitweb style = gitweb
Installation
I’ll be building some of this from source, since we’ll need a decent fcgiwrap (Debian has the very old version 1.0, which simply won’t work for us). We’ll need fcgiwrap 1.0.3 to run “gitweb/index.cgi”.
sudo apt-get install libfcgi-dev gitweb
cd ~/Downloads
git clone git://github.com/gnosek/fcgiwrap.git
cd fcgiwrap/
autoreconf -i
./configure
make && sudo make install
I chose fcgiwrap because I was already using it on my server and decided to find another use for it. The GitWeb page on GitHub has instructions for gunicorn.
Configuration
I rewrote the original (read: old Debian) fcgiwrap init script, which you can get here.
Copy it to “/etc/init.d”.
Without the script, you can start it like this:
fcgiwrap -s tcp:127.0.0.1:8088 -f
With the script, like this:
service fcgiwrap start
Now let’s move on to Nginx. Edit “/etc/nginx/nginx.conf”:
upstream gitweb {
server 127.0.0.1:8088;
}
And your virtual host file:
server {
listen 80;
server_name gitweb.example.org;
root /usr/share/gitweb;
location ~* \.(jpg|txt|jpeg|gif|png|ico|css|zip|js|swf)$ {
expires 0;
}
location / {
fastcgi_pass gitweb;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param SCRIPT_FILENAME $document_root/index.cgi;
}
}
Open “/etc/gitweb.conf” and specify the path to the repositories:
# path to git projects (<project>.git)
$projectroot = "/home/git/repositories";
...
Restart Nginx and enjoy!
nginx -s reload
What about git-instaweb?
It’s a simple GitWeb-based browser for your repository, but what if you have several repositories? This solution has one drawback: it isn’t designed to run on multiple repositories. More precisely, you’ll have to run an instance for each repository on different ports and proxy to them.
git instaweb --httpd=webrick [--start | --stop | --restart]
# --httpd поддерживает apache2, lighttpd, mongoose и webrick (по умолчанию lighttpd).
# --local слушает только локальный интерфейс (127.0.0.1)
# --port можно указать нужный порт (по умолчанию 1234)
You can also specify the settings you need for instaweb in “.gitconfig”:
[instaweb]
httpd=webrick
Further reading:
Pro Git 4.6 Git on the Server GitWeb
How To: Install and Configure GitWeb
Comments are closed. Read the original discussion in Russian →
