Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Ubuntu 12.10 Server in a virtualbox VM.

I have installed mod_python using apt-get,enabled it using a2enmod, and rebooted apache2. I have also edited \etc\apache2\sites-available\defaults as below. My script resides in /var/www/py/ and is called via a jQquery.ajax post function. This script is triggering, but returns itself - in plain text. It should be returning json, indicating that I have missed some obvious setup step.

Uncommenting the testhandler line, below, results in the script returning mod_python.testhandler output - essential the php.info() output, but for python.

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks Indexes MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

         ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride All
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        <Directory /var/www/py>
                Options Indexes FollowSymlinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                AddHandler mod_python .py
                #PythonHandler mod_python.testhandler
                PythonDebug On
        </Directory>
share|improve this question
1  
I can't understand what is the problem here. What are you expecting?, it is a response header problem?, did you encode your response in json inside your python script?. Please add more detail. BTW, mod_python is deprecated you should try to use wsgi. –  Javier Rivera Jan 28 '13 at 8:17
add comment

1 Answer

As a non-answer to your question: mod_python is no longer the recommended way of deploying python applications. Turning your application into a proper wsgi app and using mod_wsgi is the state of the art.

Now for an actual answer: You'll need to set up a handler. mod_python doesn't just run random scripts, but you need to specify which module contains the handler, this is what AddHandler does.

For more info, see the mod_python tutorial.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.