hgweb.cgi 404 未找到

hgweb.cgi 404 not found

我花了 20 小时试图解决这个问题。

我用 Redmine + Mercurial 有一个完美运行的系统。

然后我把它虚拟化并重新安装了所有东西。

Redmine 现在可用,但 Mercurial 不行。

它总是抛出 404 Not Found 或 500 Internal Server Error(如果 repo 名称错误)。

我试过很多东西,包括删除 Redmine 身份验证。

repos.tracker.conf 已启用站点:

<VirtualHost *:80>
 ServerName repos.tracker.intranet.****.com.ar
 DocumentRoot /var/www/repos.dev01/
 ServerAlias www.repos.tracker.intranet.****.com.ar repos.****.com.ar
 ServerAdmin jsivil@****.com.ar
 LogLevel warn
 ErrorLog /var/log/apache2/repos_error
 CustomLog /var/log/apache2/repos_access combined

 PerlLoadModule Apache2::Redmine
 #PerlLoadModule Apache::DBI
 ScriptAliasMatch "^/hg(.*)" "/opt/repos/hgwebdir.cgi"
 <LocationMatch "^/hg">
    AuthType Basic
    AuthName "Redmine Mercurial Repository"
    Require valid-user

    #Redmine auth
    PerlAccessHandler Apache::Authn::Redmine::access_handler
    PerlAuthenHandler Apache::Authn::Redmine::authen_handler
    RedmineDSN "DBI:mysql:database=redmine;host=127.0.0.1"
    RedmineDbUser "redminedb"
    RedmineDbPass "redminepass"
 </LocationMatch>

</VirtualHost>

tracker.conf:

<VirtualHost *:80>
        ServerAdmin jsivil@****.com.ar
        ServerName tracker.intranet.****.com.ar
        ServerAlias www.tracker.intranet.****.com.ar
        DocumentRoot /var/www/dev01
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/dev01>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

/opt/repos/hgweb.cgi

#!/usr/bin/python2.7
#
# An example hgweb CGI script, edit as necessary
# See also https://www.mercurial-scm.org/wiki/PublishingRepositories

# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/opt/repos/hgweb.config"
# Uncomment and adjust if Mercurial is not installed system-wide
# (consult "installed modules" path from 'hg debuginstall'):
#import sys; sys.path.insert(0, "/path/to/python/lib")

# Uncomment to send python tracebacks to the browser if an error occurs:
#import cgitb; cgitb.enable()

from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)

/opt/repos/hgweb.config

[paths]
/=/opt/repos/hg/**

[web]
allow_push = *
push_ssl = false
allowbz2 = yes
allowgz = yes
allowzip = yes
baseurl = /hg

权限:

root@tracker:/opt/repos/hg# ls -la
total 16
drwxrw-r-- 4 www-data root 4096 ene  1 15:37 .
drwx------ 3 www-data root 4096 ene  1 15:37 ..
drwxrw-r-- 3 www-data root 4096 oct  5 21:35 animalizate
drwxrw-r-- 3 www-data root 4096 oct  5 22:11 mercurial-hooks

我终于修正了这个错误。

我使用了 /usr/share/doc/mercurial/examples/hgweb.wsgi

中的脚本

然后 404 错误消失了。