0

I'm having a problem getting CGI to work for Python.

I've added

Options ExecCGI
AddHandler cgi-script cgi py pl

inside /etc/apache2/sites-available/default within

and now Perl works, but Python gives out a 500 Internal Server Error..

EDIT:

This if the current 'default' file

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <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
    </Directory>

    ScriptAlias /cgi-bin/ /var/www/cgi-bin/
    <Directory "/var/www/cgi-bin/">
            Options +ExecCGI
            AddHandler cgi-script .cgi .py .pl
            Allow from all
    </Directory>

Any ideas?

7
  • 1
    do you have #!/usr/bin/python as the first line of your .py files? Commented Feb 7, 2010 at 1:41
  • Yes I do. The .py file has that and just print "Hello World" below it Commented Feb 7, 2010 at 1:44
  • 1
    And did you do a chmod ugo+x on the file? Commented Feb 7, 2010 at 1:54
  • Yes I did. I've tried every possible file permission Commented Feb 7, 2010 at 1:58
  • Don't you need to print a Content-Type header? Commented Feb 7, 2010 at 1:58

2 Answers 2

1

Try renaming the .py files to .cgi, it worked for me.

Sign up to request clarification or add additional context in comments.

Comments

0

Try using the python CGI server instead of apache,if that can meet your needs.

python -m CGIHTTPServer {port number:default 8000}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.