How to get gitweb setup with nginx + uwsgi?
To
git@vger.kernel.org
From
koocr@mailc.net
Date
2019-08-12 15:09:22 UTC
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!