Apache and Python and Ubuntu

M

msuemnig

I've create an Ubuntu Linux box, which comes pre-installed with Python
(I've added the libapache2-mod-python throught the app manager). I've
created .cgi and .py simple programs in the www root of apache.

The problem is the programs just dump the contents to the browser in
plain text. Or, in the case of the .py files, I am prompted to
download the .py file. How can I get apache to recognize that it
should execute the .cgi script?

Is there any special thing I need to do to apache to get it to know
that the python interpreter should be used for all .cgi files?

Thanx all for your help in advance!
pen
 
G

grahamd

I've create an Ubuntu Linux box, which comes pre-installed with Python
(I've added the libapache2-mod-python throught the app manager). I've
created .cgi and .py simple programs in the www root of apache.

The problem is the programs just dump the contents to the browser in
plain text. Or, in the case of the .py files, I am prompted to
download the .py file. How can I get apache to recognize that it
should execute the .cgi script?

Is there any special thing I need to do to apache to get it to know
that the python interpreter should be used for all .cgi files?

You do not need mod_python if you want to use Python in traditional
CGI scripts. Simply follow the Apache instructions for setting up
CGI scripts and ignore mod_python all together.

If you really did want to use mod_python, consider reading:

http://www.dscpl.com.au/articles/modpython-001.html

It provides more detailed instructions on getting a first test handler
running.

Graham
 
J

Jorge Godoy

The problem is the programs just dump the contents to the browser in
plain text. Or, in the case of the .py files, I am prompted to
download the .py file. How can I get apache to recognize that it
should execute the .cgi script?

Is there any special thing I need to do to apache to get it to know
that the python interpreter should be used for all .cgi files?

You should configure your Apache:

- http://httpd.apache.org/docs/2.2/
- http://httpd.apache.org/docs/2.2/howto/cgi.html


--
Jorge Godoy <[email protected]>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
 
M

msuemnig

Thanx a lot for your input and advice. I went through the
documentation on httpd.apache.org/docs/2.2/howto/cgi.html and added the
following:
AddModule cgi-script .cgi .py
<DIRECTORY /var/www/>
Options +ExecCGI
</DIRECTORY>

It now gives me a 403 forbidden. When I check the error logs, it still
says that Options ExecCGI is not turned on in /var/www/

Is there a special place inside of apache2.conf I'm supposed to have
the <Directory..> tag? and/or AddModule line?

I also double checked to make sure owner/group/other all have execute
and it does.
 
P

Paul Boddie

Thanx a lot for your input and advice. I went through the
documentation on httpd.apache.org/docs/2.2/howto/cgi.html and added the
following:
AddModule cgi-script .cgi .py
<DIRECTORY /var/www/>
Options +ExecCGI
</DIRECTORY>

Does Apache actually support "DIRECTORY" as opposed to "Directory"? The
configuration file isn't "old-school HTML", and I'd recommend following
the conventions in the documentation as closely as possible until you
have something working.
It now gives me a 403 forbidden. When I check the error logs, it still
says that Options ExecCGI is not turned on in /var/www/

Is there a special place inside of apache2.conf I'm supposed to have
the <Directory..> tag? and/or AddModule line?

I would imagine that you're not supposed to be editing apache2.conf
unless the changes are fairly important and change the global
configuration of the server. On Debian/Ubuntu, you're supposed to add
files to the /etc/apache2/sites-available directory and then use the
a2ensite program to enable the new site.
I also double checked to make sure owner/group/other all have execute
and it does.

You could also investigate the ScriptAlias directive to permit access
to a particular file or directory as a CGI program (or a collection of
CGI programs) at (or under) a specified location; I've found that to be
much more convenient.

Paul
 
M

msuemnig

Paul,

thank you so much for your information and help! That was exactly the
issue.

I added ExecCGI and addHandler cgi-script .cgi to the
sites-available/default file and bounce the service and it's working!

Thanx again!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top