开发者

Using Mercurial and Apache

开发者 https://www.devze.com 2023-02-02 21:56 出处:网络
I\'m using Mercurial 1.7 and Apache 2.2.3. I\'m trying to use the hgwebdir.cgi script to authenticate and serve my repositories, which are located at /var/lib/mercurial-server/repos.

I'm using Mercurial 1.7 and Apache 2.2.3. I'm trying to use the hgwebdir.cgi script to authenticate and serve my repositories, which are located at /var/lib/mercurial-server/repos.

Although the authentication works, the webpage does not show any of the repositories.

This is my /var/www/cgi-hg/hgwebdir.cgi:

config = "/var/lib/mercurial-server/repos/"
import sys; sys.path.insert(0, "/usr/lib64/python2.4/")
import cgitb; cgitb.enable()

from mercurial import demandimport; demandim开发者_运维问答port.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)

This is my /var/www/cgi-hg/hgwebdir.config:

[collections]
/var/lib/mercurial-server/repos=/var/lib/mercurial-server/repos

[web]
allow_push = *
style = gitweb
push_ssl = False

This is my /etc/httpd/conf/httpd.conf (parts where changes were made):

DocumentRoot "/var/www/cgi-hg"

<Directory />
 Options ExecCGI FollowSymLinks
 AllowOverride None
 Order allow,deny
 Allow from all
</Directory>

<Directory "/var/www/cgi-hg">
 Options ExecCGI Indexes FollowSymLinks
 AllowOverride None
</Directory>

DirectoryIndes index.html index.html.var hgwebdir.cgi

ScriptAlias /hg "/var/www/cgi-hg/hgwebdir.cgi"

<Location /hg>
 AuthType Basic
 AuthName "Login Required"
 AuthUserFile /usr/local/etc/users
 Require valid-user
</Location>

Using config = "/var/lib/mercurial-server/repos/" and config = "/var/hg/hgwebdir.config" in hgwebdir.cgi gives me the empty repository page. Even though there is NO hgwebdir.config in /var/hg/.

Using config = "/var/www/cgi-hg/hgwebdir.config" gives me a page showing OSError. Part of the page shows:

/var/www/cgi-hg/hgwebdir.cgi
(highlighted) 22 application = hgweb(config)
application undefined, hgweb = <function hgweb>, config = '/var/www/cgi-hg/hgwebdir.config'

/usr/lib64/python2.4/site-packages/mercurial/hgweb/__init__.py in hgweb(config='/var/www/cgi-hg/hgwebdir.config', name=None, baseui=None)
(highlighted) 26 return hgwebdir_mod.hgwebdir(config, baseui=baseui)
...

I also noticed that whenever I restart my httpd, I get the 2 messages:

Starting httpd: [date time] [warn] The ScriptAlias directive in /etc/httpd/conf/httpd.conf at line 570 will probably never match because it overlaps an earlier ScriptAliasMatch.
httpd: Could not reliably determine the server's fully qualified domain name, using <IP address> for ServerName

There is no ScriptAliasMatch in my httpd.conf.

When I point my browser to /hg, I'm asked to authenticate, then I either get the empty repository page, or the Python errors, depending on which config I use in the hgwebdir.cgi.

If I use "hg serve --webdir-conf /var/www/cgi-hg/hgwebdir.config", all my repositories show up correctly.

I'm very new to apache, so I'm sure I've gotten something wrong. Please advise.

Thank you.


I don't know about the ScriptAlias warning, but I think line of your /var/www/cgi-hg/hgwebdir.cgi file should be changed from the current:

config = "/var/lib/mercurial-server/repos/"

to

config = "/var/www/cgi-hg/hgwebdir.config"

When you're serving a single repo it's the path to that repo, and when you're serving multiple files it's the path to the hgweb configuration file.

You can make sure that it's reading your hgwebdir.config file by changing the style to something very noticable like coal (which is dark gray). If you don't see that change then it's just running with defaults.

Once you get things going you should lock down that Apache config a bit too. One's DocumentRoot is usually soemthing other than the directory containing the CGIs (you don't want people trolling around the areas outside of /hg) and similarly you shouldn't have ExecCGI option enabled for the whole files system (Directory /) as a general rule.

First, though, make sure it's actually reading your hgwebdir.config file and then work on that.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号