I was trying to configure python to apache2 as suggested by http://ubuntuforums.org/showthread.php?t=91101

  1. First downloaded and installed and enabled mod_python module
  2. Changed /etc/apache2/sites-available/default as specified

    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride AuthConfig
        Order allow,deny
        allow from all
        AddHandler mod_python .py
        PythonHandler mod_python.publisher
        PythonDebug On
        # Uncomment this directive is you want to see apache2's
        # default start page (in /apache2-default) when you go to /
        #RedirectMatch ^/$ /apache2-default/
  3. created test.py in my /var/www and restarted apache.

  4. Getting 404-Not Found error for localhost/test.py

  5. On my error.log i have

    [Sun Apr 10 14:07:04 2011] [notice] mod_python (pid=5591, interpreter='localhost.localdomain'): Importing module '/var/www/test.py'

I am using Ubuntu-10.10. Anyone any ideas ???

UPDATE enter image description here


I think the folder is /var/www and NOT /www/var.

Did you add:

#!/usr/bin/env python

As the first line in your python script? If not it won't be recognized as a python script.

Also try to disable the plugin and tell me if it outputs the contents of the file when you go to localhost/test.py.

I hope this helped you, Daniel

  • thanks for your interest @Daniel0108, but still i m getting the above error-page. – Santosh Linkha Apr 10 '11 at 11:07
  • did you disable the plugin and tried to open the script? – omnidan Apr 10 '11 at 11:58
  • you mean changing the to the conf file or disabling the module?? – Santosh Linkha Apr 10 '11 at 12:22
  • have you checked the file permissions? perhaps you should try to set the file with 777 and give it a go.. – Pavlos G. Apr 10 '11 at 12:48
  • 1
    i think it was working from the first. first i put print "hello" .. it gave me 404 error. and then i put def index(req): return "Test successful"; it gave me test successful. I am total newbie. perhaps i should go though an ebook or so. – Santosh Linkha Apr 11 '11 at 4:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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