On Tue, Aug 14, 2018 at 02:24:30AM -0700, christian.tre...@itsv.at wrote:

> i am trying to set up gitweb and the http backend. gitweb works so far, but 
> the http backend is giving me headaches. i always get "fatal: repository  
> not found  errors, which is quite frustrating as gitweb works perfectly 
> well with the same url. i wasted hours on this, so any help would be really 
> nice!

Setting this stuff right might indeed be tricky.

I would highly recommend you to first disable mod_rewrite altogether and
try to get it working without it. The reason is that in my personal
experience (with web developers) using mod_rewrite is their first and
often the sole tactic in trying to solve any issue of mapping URLs to
the filesystem, and unfortunately, mod_rewrite is another moving part in
the already complicated gizmo, and the way it moves is not obvious.

Okay, the way Git works via HTTP is actually documented in [1],
and trust me, you're supposed to read it several times to understand
completely.

One of the major takeaways from it is that base part of your "Git" URL
must be mapped to the filesystem pathname of the `git-http-backend`
binary installed in your system. IOW, if you cant, say, your repos to be
located via, say, "http://test.sozvers.at/git/..."; URLs, the base path
"/git/" (notice the trailing slash!) on the vhost serving
"test.sozvers.at" must map exactly to something like
"/usr/lib/git-core/git-http-backend/" (notice the trailing slash,
again!). The pathname shown is okay for Git packaged for Debian (and its
derivatives; check the package provided by your OS) to find out where
the git-http-backend binary is located on your system.

A typical way to map base pathnames from URLs to the git-http-backend
binary is through the ScriptAlias directive, like in

Here is a skeleton example of a vhost serving both Git and Gitweb:

<VirtualHost *:80>
        ServerName  git.domain.local
        ServerAlias git

        ServerAdmin webmaster@domain.local

        DocumentRoot /var/www/git

        <Directory /var/www/git>
                Require all denied
                AllowOverride none
                Options none
        </Directory>

        <Directory /var/www/git/gitweb>
                Options +FollowSymLinks +ExecCGI
                AddHandler cgi-script .cgi
        </Directory>

        ScriptAlias /git/ /usr/lib/git-core/git-http-backend/
</VirtualHost>


To make it fully working, you'd have to set up the GIT_PROJECT_ROOT
environment variable in your vhost config for Git to be able to find
the repositories. See [1] for more info.


After having the basic stipped down setup working, you may add
proper <Location> directives to tighten access controls, if needed.


One another possible caveat is that if you're using mod_suexec to make
Git repos be served using the credentials of a dedicated user -
different from that of the web server process is using - stuff gets more
complicated as mod_suexec strips all the environment variables set in
the vhost config. If you have this situation, ask away as I have a
workaround.

1. 
https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-http-backend.html

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to