0

I have setup my repo at /home/adil/hg/sample-repo and want to serve it via httpd. I am following the tutorial at https://www.mercurial-scm.org/wiki/PublishingRepositories#multiple and have created the hgweb.config file and have copied hgweb.cgi (renamed it to index.cgi) to /home/adil/web/mercurial/

My apache config (/etc/httpd/conf/httpd.conf) looks like this :

ScriptAlias /hg "/home/adil/web/mercurial/index.cgi"

<Directory "/home/adil/web/mercurial">
    Order allow,deny
    Allow from all
    AllowOverride All
    Options ExecCGI
    AddHandler cgi-script .cgi
</Directory>

index.cgi, hgweb.config and all the dirs upwards have world read permissions

http://localhost/hg gives a "403 Forbidden" error. WTF?

PS: Apache error log shows : [Sun Oct 17 06:45:38 2010] [error] [client 1.2.3.4] (13)Permission denied: access to /hg denied

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Adil
  • 2,092
  • 3
  • 25
  • 35

2 Answers2

1

I'm not an Apache config expert by any means, but I was experiencing this error and managed to get rid of it.

Before I did, I was getting this error in my error_log: client denied by server configuration: /Users/svn/Public/hg/hgwebdir.cgi

This was my original config:

ScriptAlias /hg "/Users/svn/Public/hg/hgwebdir.cgi"
<Location /hg>
   AuthType Basic
   AuthName "Mercurial Repositories"
   AuthUserFile /Users/svn/Public/hg/auth
   Require valid-user
</Location>

I added some options:

ScriptAlias /hg "/Users/svn/Public/hg/hgwebdir.cgi"
<Location /hg>
  Options ExecCGI FollowSymLinks
  Options None
  Order allow,deny
  Allow from all

  AuthType Basic
  AuthName "Mercurial Repositories"
  AuthUserFile /Users/svn/Public/hg/auth
  Require valid-user
</Location>

I tried Pablo's version too - one problem I experienced was that "ScriptAliasMatch ^/hg(.*)" was capturing the hg logo and stylesheets needed to render the browser repo explorer. I'm not sure if this even applies to hgweb.cgi because I don't use that one, but it was definitely an issue while using hgwebdir.cgi. Specifically: script not found or unable to stat: /Users/svn/Public/hg/hgweb.cgilogo.png

drhr
  • 2,261
  • 2
  • 17
  • 35
0

Probably Apache's process owner does not have permissions to access /home/adil/web/mercurial.

Also, do check Apache's error log (usually located in /var/log/httpd-error.log or some place similar. It will give you extra information to debug your installation.

To check what's the user running Apache's process do:

$ ps aux | grep http

ps should show what's the user running Apache.

Also, in case it helps, here's the way I do it:

ScriptAliasMatch        ^/hg(.*)        /usr/local/share/mercurial/www/hgweb.cgi$1
<Directory /usr/local/share/mercurial/www>
  Options ExecCGI FollowSymLinks
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all
</Directory>
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292