我无法让dwww工作 - 一直显示404页面未找到

当我试图在由dwww生成的网页上点击链接时,我会收到以下错误提示:
Not Found

The requested URL /cgi-bin/dwww/usr/share/doc/ was not found on this server.

Apache/2.4.10 (Ubuntu) Server at randys-laptop Port 80

我已经安装了Debian文档浏览器软件包。
我做错了什么?
2个回答

dwww使用cgi来提供网页服务,但是在apache2中,默认情况下不再启用cgi,所以您需要启用cgi

sudo a2enmod cgi

然后使用以下命令重新启动apache2服务:
service apache2 restart

这将解决您在使用 dwww 时遇到的主要问题,即返回 not found

但是您可能会遇到另一个问题。 dwww 允许从 Web 服务器访问位于 /var/www/dwww/usr/share/doc 的文件(并且它会跟随其他目录中的符号链接到 /usr/share/doc)。

您可能会发现的另一个问题是,一些文档文件不在 /usr/share/doc 中。

例如(这取决于您安装了哪些文档),/usr/share/gtk-doc/html 中的某些目录被符号链接到 /usr/share/doc/...。这些将在 dwww 中正常显示。

但其他文件则不会自动显示。例如,/usr/share/gtk-doc/html/atk 目录不使用符号链接到 /usr/share/doc。尝试使用 dwww 打开这些文件会导致:

dwww will not allow you to read the file /usr/share/gtk-doc/html/atk/index.html 

可能有一个解决方案,涉及到apache2/dwww配置;但我对apache2安全性不是很了解,也不想引入问题。
简单的解决方法是对于那些出现这个问题的(非常)少数文件,使用file://协议。
对于上面的atk文档示例,生成的URL是:
http://<server-name>/cgi-bin/dwww/usr/share/gtk-doc/html/atk/index.html?type=html

你可以点击地址栏并编辑它为:
file:///usr/share/gtk-doc/html/atk/index.html?type=html

文件将会加载。

简单的解决方法是使用file://协议。为什么不在/usr/share/doc添加符号链接呢? - undefined

关于“dwww无法让您阅读...”问题:
"dwww"只会显示在其"/etc/dwww/dwww.conf"设置的"DWWW_DOCPATH"白名单路径中的文件。
默认设置为"/usr/share/doc:/usr/share/info:/usr/share/man:/usr/local/share/doc:/usr/local/share/info:/usr/local/share/man:/usr/share/common-licenses"。它不会遵循符号链接,因此您必须手动添加它们的目标。