473,800 Members | 2,602 Online
Bytes | Software Development & Data Engineering Community
+ 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 5523

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.or g/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.or g/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
1342
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 like Java as well? Regards Ian
5
1414
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). It seems apache and everything functions fine. I tried to run the example application from the mod_python site (http://www.modpython.org/examples/psp_site.tgz) by decompressing the
5
1589
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 Ubuntu Server Edition 6.06 LTS. I'm sure it's not too far removed from the desktop edition but, clearly, I need to tweak something or install some missling libs. uname -a
1
2215
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 Session, Cookie, util def index(req):
1
4682
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 and I tried to put the mod_python module to work. the only answer I got was that apache didn't find api structure in the module. afterwards I read I didn't need this module to work with python (only a speed difference as I understand) but the problem...
3
8516
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 Python, if this is the case (can't seem to do it myself!). Anyway, I'm running a CGI script written in python that tars up the photos in user selected directories (via a form). It's running on Apache 1.3.31.1 on Solaris 5.8. It works well for a...
13
1533
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 oruc
2
2116
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 log file with php as it is always being used by apache. now i can copy using command line: cp /var/log/apache2/access.log /var/log/apache2/access.log.copy I need to do this in php but i don't no how. Please help Thanks Scott.
3
1597
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 results. Is it possible that My Buddy is trying to foole me or is it possible that someone knows something about that.
2
1147
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
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10279
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10255
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9092
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6815
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5473
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5607
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4150
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 we have to send another system
2
3765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.