473,395 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Apache and Python and Ubuntu

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

Mar 29 '06 #1
5 5495

msuem...@jjhill.org wrote:
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

Mar 29 '06 #2
ms******@jjhill.org writes:
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 <go***@ieee.org>

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Mar 29 '06 #3
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.

Mar 29 '06 #4
ms******@jjhill.org wrote:
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

Mar 30 '06 #5
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!

Mar 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ian Pellew | last post by:
Hi all; Am I correct in thinking that Mod_Python simply executes Python scripts from the server side using an internal Apache python engine? Can a web page have Python script embedded in it...
5
by: Ido Yehieli | last post by:
Hi all, I have succesfully installed apache+mod_python (ubuntu 5.10 (Breezy), libapache2-mod-python2.4 Version: 3.1.3-3ubuntu1, apache2 Version: 2.0.54-5ubuntu4, python2.4 Version: 2.4.2-1). ...
5
by: Py PY | last post by:
(Apologies if this appears twice. I posted it yesterday and it was held due to a 'suspicious header') I'm having a hard time trying to get a couple of tests to pass when compling Python 2.3.5 on...
1
by: bashustbiju | last post by:
Hi Please some one help for configuring apache to use python scripts I made some changes. the index.py script contains the entry from mod_python import apache from mod_python import...
1
by: wadacom | last post by:
I'm sorry to take your time for newbie problems but I've been searching what to do about the problem with my apache server I have. I work with ubuntu dapperdrake I put the last apache server on it...
3
by: falloutphil | last post by:
Hi, First of all sorry for the double post - this is on the Python page too, but as far as I can see this is an Apache issue now. Mods - feel free to delete the similar titled posts from me on...
13
by: oruccim | last post by:
hii my friends; I want to create picture of security code.can i do it ? if yes,how , which module will help me? have you got a example that can create a picture whit my name pls help me thansk...
2
by: ratcateme | last post by:
Hi i am using php 5.2.3 on Ubuntu 7.10 and apache 2.2.4. i have just switched from windows 2000 and have encountered a problem with my log viewer script unlike windows i cannot just open the apache...
3
by: azrael | last post by:
Hy folks A friend of mine told me something about Guido and google developing an Ubuntu distribution based and totaly oriented for the Python appliction development. I googled for it with no...
2
by: Michael Palmer | last post by:
On Sep 5, 9:56 pm, Sean Davis <seand...@gmail.comwrote: xmlrpc is the right idea, as it interfaces easily across languages.
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.