threads / discuss / 51626

How to get gitweb setup with nginx + uwsgi?

Subject: How to get gitweb setup with nginx + uwsgi?

## tl;dr

3 messages between Aug 12, 2019 and Aug 12, 2019.

replies: 2people: 2as markdown or json

koocr@mailc.net· Aug 12, 2019, 15:09 UTC · lore
Hi all.
I'm setting up a local Git server, with Gitweb + Gitolite.
The gitolite wrapper is installed & working.  Now I'm working on the Gitweb frontend.
I run Nginx as my webserver.  Usually with PHP, using fpm.
Gitweb's gitweb.cgi looks like it needs perl CGI.
For perl cgi I'm trying to get it working with UWSGI,
	https://uwsgi-docs.readthedocs.io/en/latest/Nginx.html
	https://nginx.org/en/docs/http/ngx_http_uwsgi_module.html#example
I installed
	git --version
		git version 2.22.0
	ls -al /usr/share/gitweb/gitweb.cgi
		-rwxr-xr-x 1 root root 247K Jul 24 05:27 /usr/share/gitweb/gitweb.cgi
	grep "\$version =" /usr/share/gitweb/gitweb.cgi
		our $version = "2.22.0";
	nginx -v
		nginx version: nginx/1.17.1 
	uwsgi --version
		2.0.18
I set up the nginx vhost
	server { 
	    listen 127.0.0.1:60080 http2;
	    root /usr/share/gitweb;
	    index  gitweb.cgi;
	    location / {
	        try_files $uri $uri/ @gitweb;
	    }
	    location @gitweb {
	        root /usr/share/gitweb;
	        include uwsgi_params;
	        gzip off;
	        uwsgi_param UWSGI_SCRIPT gitweb;
	        uwsgi_param GITWEB_CONFIG /etc/gitweb/gitweb.conf;
	        uwsgi_pass unix:/run/uwsgi/uwsgi.sock;
	        uwsgi_modifier1 5;
	    }
	}
and the uwsgi server
	/etc/uwsgi/uwsgi.ini
		[uwsgi]
		strict = 1
		master = true
		processes = 2
		binary-path = /usr/sbin/uwsgi
		plugin-dir = /usr/lib64/uwsgi
		logto = /var/log/uwsgi/uwsgi.log
		uid = wwwrun
		gid = www
		umask = 022
		uwsgi-socket = /run/uwsgi/uwsgi.sock
		chmod-socket = 660
		chown-socket = wwwrun:www
		plugins = http,psgi
		chdir = /usr/share/gitweb
		psgi = gitweb.cgi
nginx & uwsgi services are both running
	ps aux | egrep "nginx|uwsgi"
		wwwrun   17463  0.0  0.1  89468 23704 ?        Ss   07:03   0:00 /usr/sbin/uwsgi --autoload --ini /etc/uwsgi/uwsgi.ini
		wwwrun   17465  0.0  0.1  97664 17184 ?        Sl   07:03   0:00 /usr/sbin/uwsgi --autoload --ini /etc/uwsgi/uwsgi.ini
		wwwrun   17468  0.0  0.1  97664 17184 ?        Sl   07:03   0:00 /usr/sbin/uwsgi --autoload --ini /etc/uwsgi/uwsgi.ini
		root     18006  0.0  0.0 211264  4276 ?        Ss   07:10   0:00 nginx: master process /opt/nginx/sbin/nginx -c /etc/nginx/nginx.conf -g pid /run/nginx.pid;
		wwwrun   18007  0.0  0.0 211416  5492 ?        S    07:10   0:00 nginx: worker process
		wwwrun   18008  0.0  0.0 212068 10300 ?        S    07:10   0:00 nginx: worker process
		wwwrun   18009  0.0  0.0 211416  5492 ?        S    07:10   0:00 nginx: worker process
		wwwrun   18011  0.0  0.0 211416  5492 ?        S    07:10   0:00 nginx: worker process
		wwwrun   18012  0.0  0.0 211452  5052 ?        S    07:10   0:00 nginx: cache manager process
	ls -al /run/uwsgi/uwsgi.sock
		srw-rw---- 1 wwwrun www  0 Aug 12 07:03 /run/uwsgi/uwsgi.sock=
when I go to the site
	http://127.0.0.1:60080/
I just get the script listing in the browser
	#!/usr/bin/perl
	 
	# gitweb - simple web interface to track changes in git repositories
	#
	# (C) 2005-2006, Kay Sievers <kay.sievers@vrfy.org>
	# (C) 2005, Christian Gierke
	#
	# This program is licensed under the GPLv2
	 
	use 5.008;
	use strict;
	use warnings;
	...
no errors anywhere, just the script display.
I'm missing something basic since it's not running the script. :-/
Anyone have any experience with gitweb + uwsgi on nginx?  Or know a good working example?
Thanks!
Konstantin Ryabitsev· Aug 12, 2019, 19:16 UTC · re: koocr@mailc.net · lore

Re: How to get gitweb setup with nginx + uwsgi?

On Mon, Aug 12, 2019 at 08:09:22AM -0700, koocr@mailc.net wrote:
>Hi all.
>
>I'm setting up a local Git server, with Gitweb + Gitolite.

We have it working in a similar configuration, but with CGit instead of GitWeb. Unless you have specific requirements to run GitWeb, I recommend you use CGit for your web frontend, as it offers many features GitWeb doesn't, such as caching -- plus it works really well with uwsgi (git.kernel.org runs in that configuration).

Best, -K

koocr@mailc.net· Aug 12, 2019, 21:49 UTC · re: Konstantin Ryabitsev · lore

Re: How to get gitweb setup with nginx + uwsgi?

Hi,
On Mon, Aug 12, 2019, at 12:16 PM, Konstantin Ryabitsev wrote:
Show 5 quoted lines
> We have it working in a similar configuration, but with CGit instead of 
> GitWeb. Unless you have specific requirements to run GitWeb, I recommend 
> you use CGit for your web frontend, as it offers many features GitWeb 
> doesn't, such as caching -- plus it works really well with uwsgi 
> (git.kernel.org runs in that configuration).
Didn't realize that!  
I'd picked gitweb in the first place as I figured, being part of git, that kernel project would be using it.
Clearly I'm wrong.
Switching to CGit now.  Thanks for the suggestion.
I don't use Arch (Opensuse User), but am trying to follow their CGit + UWSGI + Gitolite docs:
https://wiki.archlinux.org/index.php/Cgit#Using_uwsgi
Since my distro pkgs have different paths, systemd setup, etc. having some challenges getting a everything-working-together config setup.  That'll just take some reading and staring ! ;-)
If you know of any other good examples , please share :-)
TA!

← back to recent threads