`apache2ctl restart` 让 apache 忘记 cgi-bin

Dan*_*tin 6 debian apache-2.4

在我的 Debian 机器上(运行由 Debian 打包的 apache,包 2.4.7-1),每次 apache 通过apache2ctl restartor重新启动时apache2ctl graceful,它都会忘记我的 cgi-bin 目录:

me@aram:~$ sudo apache2ctl graceful-stop
me@aram:~$ sudo apache2ctl graceful
httpd not running, trying to start
me@aram:~$ curl -s http://localhost/cgi-bin/hello
Hello world, from a cgi script.
me@aram:~$ sudo apache2ctl graceful
me@aram:~$ curl -s http://localhost/cgi-bin/hello
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /cgi-bin/hello was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Debian) Server at localhost Port 80</address>
</body></html>
me@aram:~$ sudo apache2ctl graceful
me@aram:~$ curl -s http://localhost/cgi-bin/hello
Hello world, from a cgi script.
me@aram:~$ sudo apache2ctl graceful; sudo apache2ctl graceful
me@aram:~$ curl -s http://localhost/cgi-bin/hello
Hello world, from a cgi script.
me@aram:~$ sudo apache2ctl graceful
me@aram:~$ curl -s http://localhost/cgi-bin/hello
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /cgi-bin/hello was not found on this server.</p>
<hr>
<address>Apache/2.4.7 (Debian) Server at localhost Port 80</address>
</body></html>
me@aram:~$ sudo apache2ctl graceful
me@aram:~$ curl -s http://localhost/cgi-bin/hello
Hello world, from a cgi script.
Run Code Online (Sandbox Code Playgroud)

这是完全可重复的;如果我完全停止服务器并重新启动它,就可以了。之后,重启(正常与否)会切换行为。不幸的是,常规logrotate作业会正常重启,所以我需要让它让 Apache 始终知道cgi-bin.

访问或错误日志中没有任何内容可以标记从“不知道 cgi”重新启动“将知道 cgi”重新启动。如果人们对如何使日志更详细的建议发表评论,我会尝试并更新它。

我正在使用 Debian 软件包附带的配置(因此它是通过将-enabled目录中的一堆文件符号链接到目录中的现有文件来配置的-available)。在这里,作为参考,是我的-enabled目录包含的内容:

me@aram:/etc/apache2$ ls *-enabled
conf-enabled:
000-local-routerblock.conf  charset.conf  javascript-common.conf      other-vhosts-access-log.conf  serve-cgi-bin.conf
apache2-doc.conf            dwww.conf     localized-error-pages.conf  security.conf

mods-enabled:
access_compat.load  authn_core.load       authz_host.load  cgi.load      dir.load    filter.load       mpm_prefork.load  reqtimeout.load  status.load
alias.conf          authn_file.load       authz_user.load  deflate.conf  dnssd.conf  mime.conf         negotiation.conf  setenvif.conf    userdir.conf
alias.load          authz_core.load       autoindex.conf   deflate.load  dnssd.load  mime.load         negotiation.load  setenvif.load    userdir.load
auth_basic.load     authz_groupfile.load  autoindex.load   dir.conf      env.load    mpm_prefork.conf  reqtimeout.conf   status.conf

sites-enabled:
000-default.conf
Run Code Online (Sandbox Code Playgroud)

所有这些,除了000-local-routerblock.conf,都是由 Debian 提供的。我已经验证删除该配置文件可以解决问题,所以我怀疑该文件和默认serve-cgi-bin.conf文件之间存在一些奇怪的交互。然而,日志中没有任何证据。

内容000-local-routerblock.conf

Redirect /router /cgi-bin/router
<Location "/cgi-bin/router">
  AuthUserFile /usr/lib/cgi-bin/routerblock/htpasswd
  AuthGroupFile /dev/null
  AuthName ByPassword
  AuthType Basic
  Require user router
</Location>
Run Code Online (Sandbox Code Playgroud)

内容serve-cgi-bin.conf

<IfModule mod_alias.c>
    <IfModule mod_cgi.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfModule mod_cgid.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfDefine ENABLE_USR_LIB_CGI_BIN>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Require all granted
        </Directory>
    </IfDefine>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Run Code Online (Sandbox Code Playgroud)

编辑:我现在已经解决了这个问题,就“我让它工作”而言。我不知道为什么会这样,而且它几乎可以肯定表明此版本的 Apache 中存在错误。我将赏金留给某人回答正在/正在发生的事情。

无论如何,解决方案不在任何配置中。我引用的文件。请记住,此配置的其余部分完全是 Debian 的库存,配置没有任何自定义。Debian/etc/apache2/apache2.conf包括以下行:

LogLevel warn
Run Code Online (Sandbox Code Playgroud)

在 stock 配置中,LogLevel除了文件中注释掉的一个语句外,没有其他语句/etc/apache2/sites-available/000-default.conf。(整个文件都在一个<VirtualHost *:80>标签内;它设置了DocumentRoot访问日志,但没有其他内容)

我是瞎搞与LogLevel设置的尝试,当我遇到这个偶然得到在我的日志的详细信息:如果我有一个LogLevel这里面的语句VirtualHost标签,它的工作原理。所以,现在,除了LogLevel warn这是在主Apache的配置,我也有一个LogLevel warn内部<VirtualHost *:80>的标签000-default.conf。这有效。如果这个周末我有额外的时间,我想我会尝试设置一个虚拟机,在尽可能干净的环境中重现它,然后提交一个 Debian 错误。

Chr*_*s J 1

根据上面的评论和错误报告链接,这似乎是一个最近已解决的有效错误;来自https://bugs.debian.org/743860

\n\n
\n

发件人:Jean-Michel Vourg\xc3\xa8re
\n 致:743860-done@bugs.debian.org
\n 主题:回复:apache2:Apache 在重新启动时忘记 /cgi-bin
\n 日期:2015 年 6 月 8 日星期一 00 :12:12 +0000

\n\n

来源:apache2 来源版本:2.4.10-1

\n\n

你好

\n\n

我们相信您报告的错误已得到修复。

\n\n

感谢您报告该错误,该错误现已关闭。如果您有进一步的意见,请将其发送至 743860@bugs.debian.org,维护人员将在适当的情况下重新打开错误报告。

\n
\n