3

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

1 Answer 1

4

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

8
  • thanks for your interest @Daniel0108, but still i m getting the above error-page.
    – S L
    Apr 10, 2011 at 11:07
  • did you disable the plugin and tried to open the script?
    – omnidan
    Apr 10, 2011 at 11:58
  • you mean changing the to the conf file or disabling the module??
    – S L
    Apr 10, 2011 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, 2011 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.
    – S L
    Apr 11, 2011 at 4:50

You must log in to answer this question.

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