[mod_python] Why Apache does not execute cgi scripts

Tomasz Wlodek tomw at bnl.gov
Fri Feb 24 16:32:28 EST 2006

Hello experts,

I am not sure whether this issue belongs to Apache proper or mod python or

here is the problem: I use mod_python authentication handler to
authenticate users who come to some directory. This part of the code works

After the user is authenticated mod_python returns apache.OK and then
Apache is supposed to execute cgi script which is located in this
directory. For the time being the cgi script is a simple "Hello world" in

Now comes the problem: users are authenticated, then Apache takes the cgi
script but instead of executing it it displays its content as text file.

The funny thing is that the same cgi script when I move it to another cgi
directory (where I do not use mod_python for authentication) works fine.
It executes as cgi script.

Apparently when I protect a directory by mod_python authentication handler
then Apache does not want to execute underlying cgi scripts from this

Here comes the configuration file for this directory:

Alias /GridHyperNews "/var/www/cgi-bin/GridHyperNews"
    <Directory /var/www/cgi-bin/GridHyperNews>
	AllowOverride None
	#I want the directory to contain cgi scripts
        Options +ExecCGI
	SetHandler cgi-script
	# users who come to this directory must be authenticated by
	# myhandler2
	PythonAuthenHandler myhandler2
	PythonDebug on
	PythonPath "sys.path + ['/root/mod_python_handlers']"
	require valid-user

The myhandler2.py code is very simple

from mod_python import apache
from mod_python import util

import _mp_mod_ssl
import os,string

def authenhandler(req):

    return apache.OK

Now, no matter what I do scripts under the directory
/var/www/cgi-bin/GridHyperNews are not treated by Apache as cgi but as
text files.

Tomasz Wlodek                        | tel 631-344-7448
Brookhaven Laboratory, Building 510M | fax 631-344-7616
Upton NY 11973-5000                  |

More information about the Mod_python mailing list