17

I'm configuring gitweb in my system via Apache in OpenSUSE (non-virtual host). However, I get the following error: 404 - No projects found.

/etc/gitweb.conf

# path to git projects (<project>.git)
$projectroot = "/home/zhijian/gitweb";

# directory to use for temp files
$git_temp = "/tmp";

# target of the home link on top of all pages
#$home_link = $my_uri || "/";

# html text to include at home page
$home_text = "/gitweb/static/indextext.html";

# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;

# stylesheet to use
$stylesheet = "/gitweb/static/gitweb.css";

# logo to use
$logo = "/gitweb/static/git-logo.png";

# the 'favicon'
$favicon = "/gitweb/static/git-favicon.png";

/etc/apache2/conf.d/gitweb.conf

Alias /gitweb "/home/zhijian/gitweb"

<Directory "/home/zhijian/gitweb">
    Options +Indexes +ExecCGI +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    AddHandler cgi-script .cgi
    DirectoryIndex gitweb.cgi

</Directory>

I added a soft link in the gitweb folder to link gitweb.cgi and the static folder. The Apache error log shows gitweb.cgi: Can't opendir(/home/zhijian/gitweb): Permission denied, but the permissions on the gitweb folder has been set to 755. Does anybody have an idea what might be causing this issue?

Perception
  • 79,279
  • 19
  • 185
  • 195
xuzhijian
  • 249
  • 1
  • 4
  • 10

6 Answers6

12

I've had the same problem too in OpenSuse 11.4. In my case (and I suspect this was the case for the initial poster, who is also an opensuse user), the problem turned out to be this AppArmor thing, which I know very little about.

Here's some points I noticed that led to the eventual solution:

  • In OpenSuse, the git-web rpm package installs so that the $projectroot defaults to the "/srv/git" folder
  • If you add your git repos within this "/srv/git/..." sub-folder, then everything works just fine
  • If you decide on some other location, eg, "/home/myname/srv/git/", then it fails, despite setting owner to wwwrun:www as advised in other posts.
  • The gotchya here is AppArmor, which seems to place even tighter policies on what an app is allowed to do
  • Doing an "rpm -ql git-web" will reveal a file called: "/etc/apparmor.d/usr.share.git-web.gitweb.cgi"
  • Open this file up with su/sudo so you can edit it
  • In here, you will see these lines:

...

/srv/git/ r,
/srv/git/** r,

...

  • Change these to the path of the parent-folder containing your git repos, eg, if your housing them in "/home/myname/srv/git/", then use the ""/home/myname/srv/" parent-folder, eg:

...

/home/myname/srv r,
/home/myname/srv/** r,

...

  • Save your changes to the file
  • I think you also have to change the owner of this parent folder to wwwrun:www, eg, "sudo chown -R wwwrun:www srv/"
  • restart AppArmor with "sudo rcapparmor restart"

All should be fine now :)

Gurce
  • 592
  • 7
  • 18
  • Working on SLES 11 SP 3... this is what I needed to get this thing finally up and running. Thank you! – Avindra Goolcharan Mar 04 '14 at 18:09
  • For some reason, GitWeb actually worked for me right after I installed it. Only after reboot, I got the same "no projects found" error - and this fixed it. Thanks. – Marie Fischer Oct 25 '14 at 10:45
8

The gitweb cgi has to have the same owner as the repo you're scanning. That is to say, if your $projectroot is www-data:www-data then gitweb.cgi has to be www-data:www-data too.

In addition, the directories under $projectroot also have to have the same permissions. You should be able to do a chown -R www-data:www-data . which should help. You'll want to look at permissions as well as ownership, but that is trickier and you'll want to make sure you've got it right and haven't opened any security holes.

jeremiah
  • 844
  • 9
  • 15
  • 1
    Its also worth noting that if you don't have cgi enabled in your web server you'll get "permission denied" and the script will show up as plain text. – jeremiah Jul 05 '16 at 00:39
3

I had the same problem. "404 no projects found" but the config was good. Apache cached the 404-response and did not run the cgi-script again:

  1. config in gitweb.conf was not edited (default ubuntu installation)
  2. I accessed the URL with a web browser: Got "no projects found"
  3. I updated the config
  4. I hit ctrl-r but again: "no projects found" (although the config was correct now)
  5. I hit shift-ctrl-r (Firefox) and I got the correct result!
guettli
  • 25,042
  • 81
  • 346
  • 663
3

Edit your gitweb config file found here: /etc/gitweb.conf

And change the 10th line that starts "our $projectroot" to be:

our $projectroot = "/path/to/your/git/root"

then restart your webserver, this will tell you if your webserver config setting the GIT_PROJECT_ROOT is actually working.

Beachhouse
  • 4,972
  • 3
  • 25
  • 39
0

SELinux keeps repository files unavaliable for http server also. If you have to use SELinux you must change policy. The easest way is to disable SELinux ;-)

szaroblekitny
  • 130
  • 1
  • 5
-3

set the permissions on the gitweb folder to 777. it works.

feiy
  • 1
  • 1