Apache 服务器 CGI 错误 500

Apache 服务器 CGI 错误 500

我正在尝试为 GIT 的“cgit”Web UI 设置服务器。我已从开发人员的网站下载了源代码,并根据说明对其进行了正确的编译。

我的 default-server.conf 如下所示:

#
# Global configuration that will be applicable for all virtual hosts, unless
# deleted here, or overriden elswhere.
# 

DocumentRoot "/srv/www/htdocs/cgit"

#
# Configure the DocumentRoot
#
<Directory "/srv/www/htdocs">
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs-2.2/mod/core.html#options
    # for more information.
    Options None
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    AllowOverride None
    # Controls who can get stuff from this server.
    Order allow,deny
    Allow from all
</Directory>

<Directory "/srv/www/htdocs/cgit/">
    AllowOverride None
    Options FollowSymlinks +ExecCGI
    DirectoryIndex /
    Order allow,deny
    Allow from all
</Directory>

# Aliases: aliases can be added as needed (with no limit). The format is 
# Alias fakename realname
#
# Note that if you include a trailing / on fakename then the server will
# require it to be present in the URL.  So "/icons" isn't aliased in this
# example, only "/icons/".  If the fakename is slash-terminated, then the 
# realname must also be slash terminated, and if the fakename omits the 
# trailing slash, the realname must also omit it.
#
# We include the /icons/ alias for FancyIndexed directory listings.  If you
# do not use FancyIndexing, you may comment this out.
#
Alias /icons/ "/usr/share/apache2/icons/"

<Directory "/usr/share/apache2/icons">
    Options Indexes MultiViews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
ScriptAlias /cgi-bin/ "/srv/www/cgi-bin/"

# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "/srv/www/cgi-bin">
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
</Directory>

# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES 
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
    # Note that the name of the user directory ("public_html") cannot simply be
    # changed here, since it is a compile time setting. The apache package
    # would have to be rebuilt. You could work around by deleting
    # /usr/sbin/suexec, but then all scripts from the directories would be
    # executed with the UID of the webserver.
    UserDir public_html
    # The actual configuration of the directory is in
    # /etc/apache2/mod_userdir.conf.
    Include /etc/apache2/mod_userdir.conf
    # You can, however, change the ~ if you find it awkward, by mapping e.g.
    # http://www.example.com/users/karl-heinz/ --> /home/karl-heinz/public_html/ 
    #AliasMatch ^/users/([a-zA-Z0-9-_.]*)/?(.*) /home/$1/public_html/$2
</IfModule>


# Include all *.conf files from /etc/apache2/conf.d/.
#
# This is mostly meant as a place for other RPM packages to drop in their
# configuration snippet.
#
# You can comment this out here if you want those bits include only in a
# certain virtual host, but not here.
#
Include /etc/apache2/conf.d/*.conf

# The manual... if it is installed ('?' means it won't complain)
Include /etc/apache2/conf.d/apache2-manual?conf

当我尝试通过在浏览器的 URL 栏中输入“localhost”来访问 GUI 时,我得到了“服务器错误 - 错误 500”

在错误日志(/var/log/apache2/error_log)中,每次刷新时我都会看到以下行:

[Mon Apr 23 13:52:39 2012] [error] [client ::1] Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

我尝试使用 LimitInternalRecursion 指令,并将其设置为“500”,直到无限制。据我所知,该指令没有实际问题,只是某种无限的重写循环。

答案1

您遇到的问题是由于以下这一行造成的:

DirectoryIndex /

基本上,这句话的意思是,当你访问时http://localhost,显示/--然后会显示/等。 DirectoryIndex应该指定一个文件;当你访问一个目录时,如果该文件存在,那么它会显示该文件。所以如果你有:

DirectoryIndex cgit.cgi

然后,当您访问 时http://localhost,它将显示cgit.cgi(如果它存在于该目录中)。另一个提示 - 在 中使用虚拟主机/etc/apache2/conf.d/*.conf。例如,给定与上面类似的代码,您可以在 中包含以下内容/etc/apache2/conf.d/cgit.conf

<Directory "/srv/www/htdocs/cgit">
    AllowOverride None
    Options FollowSymlinks +ExecCGI
    Order allow,deny
    Allow from all
</Directory>

然后,您就可以使用原始文件DocumentRoot/etc/apache2/httpd.conf无需修改原始文件。

相关内容