On an Ubuntu Server 14.04, I have
$ apt-show-versions apache2
apache2:amd64/trusty-updates 2.4.7-1ubuntu4.9 uptodate
Here, I installed gitweb, and tried to set it up. Eventually, I managed to get it working by adding the following to my /etc/apache2/sites-available/default-ssl.conf site:
###############
ScriptAlias /gitweb/ "/usr/share/gitweb/"
Alias /gitweb /usr/share/gitweb
Alias /gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css
<Directory "/usr/share/gitweb">
Options Indexes FollowSymlinks ExecCGI
AddHandler cgi-script .cgi
#DirectoryIndex gitweb.cgi # does not do anything?
AllowOverride None
Order allow,deny
Allow from all
</Directory>
###############
Now, when I call https://example.com/gitweb/gitweb.cgi, I do get the gitweb home page, listing my repos. The problem is, the .css, .js, etc files are not loaded. When looking at the source of the served HTML of gitweb.cgi, I can see:
<link rel="stylesheet" type="text/css" href="static/gitweb.css"/>
...
<script type="text/javascript" src="static/gitweb.js"></script>
... and since these are called from under gitweb, their full adresses are https://example.com/gitweb/static/gitweb.css; and for them in the Firefox Javascript console:
GET https://example.com/gitweb/static/gitweb.css [HTTP/1.1 500 Internal Server Error 72ms]
... or if I call those URLs directly in Firefox, I get:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
...
More information about this error may be available in the server error log.
... unfortunately, there is nothing in the error logs, because I am doing:
grep -r gitweb.css /var/log/apache2
... and absolutely nothing is returned.
So, even if I'm trying an alias:
Alias /gitweb/static/gitweb.css /usr/share/gitweb/static/gitweb.css
... it doesn't work; and I've also tried:
Alias /static/gitweb.css /usr/share/gitweb/static/gitweb.css
Alias static/gitweb.css /usr/share/gitweb/static/gitweb.css
Alias /gitweb.css /usr/share/gitweb/static/gitweb.css
... and none of this works.
So, how can I get Apache set up, so that when a request comes in for /gitweb/static/gitweb.css (in terms of web root), then it serves /usr/share/gitweb/static/gitweb.css?
Well, found something by brute force - as I still couldn't find where this errors are logged.
Anyways, the ScriptAlias directive, on its own, is enough to cause 500 Internal Server Error upon a call to
https://example.com/gitweb/static/gitweb.css.On the other hand, the
Alias /gitweb /usr/share/gitwebdirective is, on its own, enough to makehttps://example.com/gitweb/static/gitweb.cssfind and serve the right file.So, it turns out, if ScriptAlias is the first one in the code, and Alias is the second, we'll get 500 Internal Server Error regardless.
But if the order is changed, so Alias is first, and ScriptAlias second - then all seems to work fine.
So ultimately, the working code for the OP example I ended up using is: