473,480 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 5501

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
1328
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
1398
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
1558
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
2199
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
4656
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
8494
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
1511
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
2100
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
1572
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
1121
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
7048
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6743
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
6966
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...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.