0

On Apache HTTP server 2.2, the ErrorDocument has a PHP CGI script in my configuration which shows a nice message and reacts to multiple error codes and shows additional information for each. This works fine.

But after upgrading to version 2.4, it no longer executes. Instead, the full source code of that file is displayed, including the first line, see below. What's wrong here?

The config is pretty simple:

ErrorDocument 401 /cgi-bin/error.cgi
ErrorDocument 403 /cgi-bin/error.cgi
ErrorDocument 404 /cgi-bin/error.cgi
ErrorDocument 500 /cgi-bin/error.cgi

The file is owned by the correct user and group and is executable. It looks like this:

#!/usr/bin/php-cgi
<?
$errorCode = $_SERVER['REDIRECT_STATUS'];
$reqUrl = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
...

The access log contains the expected entry with the error code, like 500 or 403. The error log tells me that the client was denied in my restricted directory, with is also expected.

But why is the error document file not executed at all anymore?

Apache version is from 2.2.x to 2.4.7 on Ubuntu 14.04.

Update: conf-enabled/serve-cgi-bin.conf is activated. Here's part of my VirtualHost configuration:

<VirtualHost 1.2.3.4:80 [1:2:3::4]:80>
    ServerName example.de
    ServerAlias www.example.de
    DocumentRoot /var/www/web001
    ErrorDocument 401 /cgi-bin/error.cgi
    ErrorDocument 403 /cgi-bin/error.cgi
    ErrorDocument 404 /cgi-bin/error.cgi
    ErrorDocument 500 /cgi-bin/error.cgi
    AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xhtml+xml application/x-javascript text/
    SuexecUserGroup web001 webusers
    ScriptAlias /cgi-bin/ /var/www/web001/cgi-bin/
    AddHandler fcgid-script .php
    FCGIWrapper /var/www/web001/cgi-bin/php-fcgi .php
    <Directory "/var/www/web001">
        Options +Includes +ExecCGI
    </Directory>
</VirtualHost>
2
  • Just a guess: have a look here and search down to the discussion beginning "Another change that you may notice..." WRT the third block, that starts with ScriptAlias. If this turns out to be the problem, please write it up as an answer here!
    – goldilocks
    Commented Dec 17, 2014 at 19:12
  • I don't know how to apply that, it seems already done. See my added config above.
    – ygoe
    Commented Dec 18, 2014 at 6:31

1 Answer 1

1

Comparing the old and new default configurations in detail revealed that the cgid module was not included anymore. After enabling it, the error CGI pages work as expected again. I guess any other CGI pages would not have worked either, but I don't use them regularly so I didn't notice. Not sure if it's an Ubuntu-related change or if all Apache installations don't come with CGI enabled today.

Here's the quick fix:

a2enmod cgid

Then restart apache.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .