使用 Mercurial 和 Apache

发布于 2024-10-10 08:31:56 字数 2575 浏览 3 评论 0原文

我正在使用 Mercurial 1.7 和 Apache 2.2.3。我正在尝试使用 hgwebdir.cgi 脚本来验证和服务我的存储库,该存储库位于 /var/lib/mercurial-server/repos。

尽管身份验证有效,但网页不显示任何存储库。

这是我的/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; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)

这是我的/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

这是我的/etc/httpd/conf/httpd.conf(更改的部分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>

在 hgwebdir.cgi 中使用 config = "/var/lib/mercurial-server/repos/" 和 config = "/var/hg/hgwebdir.config" 给我空的存储库页面。即使 /var/hg/ 中没有 hgwebdir.config 。

使用 config = "/var/www/cgi-hg/hgwebdir.config" 给我一个显示 OSError 的页面。部分页面显示:

/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)
...

我还注意到,每当我重新启动 httpd 时,我都会收到 2 条消息:

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

我的 httpd.conf 中没有 ScriptAliasMatch。

当我将浏览器指向 /hg 时,系统会要求我进行身份验证,然后我要么得到空的存储库页面,要么得到 Python 错误,具体取决于我在 hgwebdir.cgi 中使用的配置。

如果我使用“hgserve --webdir-conf /var/www/cgi-hg/hgwebdir.config”,我的所有存储库都会正确显示。

我对 apache 很陌生,所以我确信我弄错了。请指教。

谢谢。

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; demandimport.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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不念旧人 2024-10-17 08:31:56

我不知道 ScriptAlias 警告,但我认为您的 /var/www/cgi-hg/hgwebdir.cgi 文件的行应该从当前的:更改

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

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

When you are services a单个存储库是该存储库的路径,当您提供多个文件时,它是 hgweb 配置文件的路径。

您可以通过将 style 更改为非常明显的内容(例如 coal)(深灰色)来确保它正在读取您的 hgwebdir.config 文件。如果您没有看到该更改,那么它只是以默认值运行。

一旦你开始工作,你也应该锁定 Apache 配置。一个人的 DocumentRoot 通常不是包含 CGI 的目录(您不希望人们在 /hg 之外的区域闲逛),同样,您也不应该有 ExecCGI作为一般规则,为整个文件系统(Directory /)启用选项。

不过,首先请确保它实际上正在读取您的 hgwebdir.config 文件,然后进行处理。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文