多年来我已经在各种 Pi 上运行了 Mercuriual 服务器,但需要设置一台新机器并且正在挣扎,我认为这是我所得到的最后一步:
Forbidden
You don't have permission to access this resource.
Apache/2.4.52 (Ubuntu) Server at 192.168.5.3 Port 80
当我尝试从桌面计算机上的 Firefox 访问 192.168.5.3/hg 时。我很高兴看到 http://192.168.5.3 并且提供了默认的 apache 站点。
这是在运行Ubuntu的RPi4上,其固定IP地址是192.168.5.3
我遵循了这些说明,并与我发现的近年来发生的变化进行了一些混合。
https://wiki.mercurial-scm.org/HgWebDirStepByStep
我在 /etc/apache2/hg 中有一个名为 main.conf 的文件,其中包含以下内容:
WSGIScriptAliasMatch ^/hg(.*) /var/hg/script/hgweb.wsgi$1
<Directory /var/hg/script>
Order deny,allow
Allow from all
</Directory>
在 /etc/apache2/sites-available/ 我有 000-default.conf 其中包含以下内容:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
Include /etc/apache2/hg/main.conf
</VirtualHost>
<Directory /var/hg/>
Options +ExecCGI
PassEnv LANG
AddHandler hgweb .cgi
</Directory>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
我对现有文件所做的只是添加:
Include /etc/apache2/hg/main.conf & the <Directory /var/hg/> section
/var/hg/script/hgweb.wsgi 包含以下内容:
# An example WSGI for use with mod_wsgi, edit as necessary
# See https://mercurial-scm.org/wiki/modwsgi for more information
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "/var/hg/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()
# enable demandloading to reduce startup time
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb
application = hgweb(config)
此脚本在 Pi 上运行,其硬盘驱动器刚刚损坏,并且成功地为我的 Mercurial 文件提供服务,我可以毫无问题地推送和拉取。
/var/hg/hgweb.config 包含:
[paths]
bh0002 = /var/hg/bh0002
sam4sd32c_freertos=/var/hg/sam4sd32c_freertos
sqlforms=/var/hg/sqlforms
..snip..
几乎所有这些文件(除了
日志在这里:
tail -f /var/log/apache2/access.log
192.168.5.43 - - [06/Oct/2024:15:18:14 +0000] "GET /hg HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:15:25:16 +0000] "GET /hg HTTP/1.1" 403 493 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:15:25:18 +0000] "GET /hg HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:15:25:23 +0000] "GET /hg HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:15:30:41 +0000] "GET /hg HTTP/1.1" 403 493 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:15:30:43 +0000] "GET /hg HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:15:49:45 +0000] "GET /hg HTTP/1.1" 403 493 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:16:34:04 +0000] "GET /hg HTTP/1.1" 403 493 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:16:44:15 +0000] "GET /hg HTTP/1.1" 403 493 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
192.168.5.43 - - [06/Oct/2024:16:44:16 +0000] "GET /hg HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
有人能建议我错过了哪些步骤,或者这个更现代的 Ubuntu 版本可能有什么不同吗?如果有更多有帮助的信息,请告诉我,我会提供。据我所知,我使用的配置文件与发生故障的旧硬盘上的配置文件相同。尽管它已损坏并且无法再启动,但我还是能够使用 USB 转SATA 接口将它们取下。
终于找到了,因为我现在需要的是 Apache 2.4:
在/etc/apache2/hg/main.conf中
<Directory /opt/graphite/conf>
Require all granted
</Directory>
继续下一个错误...