我使用的是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 (进行了更改的部分):
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时,我都会收到两条消息:
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中使用的配置。
如果我使用"hg -webdir-conf /var/www/cgi-hg/hgwebdir.config",我的所有存储库都会正确显示。
我是apache的新手,所以我确信我搞错了。请给我建议。
谢谢。
发布于 2011-01-04 11:21:56
我不知道关于ScriptAlias的警告,但我认为您的/var/www/cgi-hg/hgwebdir.cgi文件的行应该从当前的:
config = "/var/lib/mercurial-server/repos/"至
config = "/var/www/cgi-hg/hgwebdir.config"当您提供单个存储库时,它是该存储库的路径,而当您提供多个文件时,它是hgweb配置文件的路径。
您可以通过将style更改为非常明显的值,如coal (深灰色)来确保它正在读取您的hgwebdir.config文件。如果你看不到这一变化,那么它只是在默认情况下运行。
一旦你开始工作,你也应该锁定Apache的配置。一个人的DocumentRoot通常不是包含CGI的目录(您不希望人们在/hg之外的区域中游荡),同样,作为一般规则,您不应该为整个文件系统(Directory /)启用ExecCGI选项。
不过,首先要确保它确实在读取您的hgwebdir.config文件,然后再处理它。
https://stackoverflow.com/questions/4590213
复制相似问题