Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was trying to configure python to apache2 as suggested by

  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 in my /var/www and restarted apache.

  4. Getting 404-Not Found error for localhost/

  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/'

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

UPDATE enter image description here

share|improve this question
up vote 4 down vote accepted

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/

I hope this helped you, Daniel

share|improve this answer
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
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 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.