473,657 Members | 2,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mod_python apache configuration issues

Hello all. I've been trying to get my linux server to run mod_python.
It's a Mandrake 10 linux box, and apache/mod_python are installed from rpms.
apache2-mod_python-2.0.48_3.1.3-1mdk
apache2-2.0.48-6mdk
The rpm installed the python module as:
/usr/lib/apache2-extramodules/mod_python.so

And added a config file for apache:
/etc/httpd/conf.d/16_mod_python.c onf

The apache config files contained the following before my modifications:
<IfDefine HAVE_PYTHON>
<IfModule !mod_python.c>
LoadModule python_module extramodules/mod_python.so
</IfModule>
</IfDefine>
<IfModule mod_python.c>
</IfModule>

Now after reading the docs installed into /usr/share/doc for mod_python
and going through the directions at python.org, I've also changed the
config file to add a few lines to one of the directives:

<Directory /var/www/html>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
</Directory>

Now when I put the url into a browser:
http://myserver.mydomain.com/mptest.py

I get a popup from the browser because it doesn't know how to handle
mptest.py, and it asks what you want to do with the file (open it with
an application, save it to disk, etc). I can choose to open the file
with a text editor, and all it shows is the text "hello world".

That's the output of the mptest.py script.... apache isn't feeding the
browser the code from the mptest.py, only the output. (Otherwise when I
open it in a text editor I'd see the entire mptest.py script.

Contents of the mptest.py script:
from mod_python import apache

def handler(req):
req.write("Hell o World!")
return apache.OK

I'm not a python developer, but have been working with Linux and Apache
for a number of years. I'm not sure where to go from here. It appears
that the script gets compiled - there is a mptest.pyc file in the
directory now. Why is it sending my browser the mptest.py file with the
stdout of the script?

Thanks in advance. Any help on this is appreciated.

Dave
Jul 18 '05 #1
2 2917
digidalmation wrote:
Hello all. I've been trying to get my linux server to run mod_python.
It's a Mandrake 10 linux box, and apache/mod_python are installed from
rpms.
apache2-mod_python-2.0.48_3.1.3-1mdk
apache2-2.0.48-6mdk
The rpm installed the python module as:
/usr/lib/apache2-extramodules/mod_python.so

And added a config file for apache:
/etc/httpd/conf.d/16_mod_python.c onf

The apache config files contained the following before my modifications:
<IfDefine HAVE_PYTHON>
<IfModule !mod_python.c>
LoadModule python_module extramodules/mod_python.so
</IfModule>
</IfDefine>
<IfModule mod_python.c>
</IfModule>

Now after reading the docs installed into /usr/share/doc for mod_python
and going through the directions at python.org, I've also changed the
config file to add a few lines to one of the directives:

<Directory /var/www/html>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
</Directory>

Now when I put the url into a browser:
http://myserver.mydomain.com/mptest.py

I get a popup from the browser because it doesn't know how to handle
mptest.py, and it asks what you want to do with the file (open it with
an application, save it to disk, etc). I can choose to open the file
with a text editor, and all it shows is the text "hello world".

That's the output of the mptest.py script.... apache isn't feeding the
browser the code from the mptest.py, only the output. (Otherwise when I
open it in a text editor I'd see the entire mptest.py script.

Contents of the mptest.py script:
from mod_python import apache

def handler(req):
req.write("Hell o World!")
return apache.OK

I'm not a python developer, but have been working with Linux and Apache
for a number of years. I'm not sure where to go from here. It appears
that the script gets compiled - there is a mptest.pyc file in the
directory now. Why is it sending my browser the mptest.py file with the
stdout of the script?

Thanks in advance. Any help on this is appreciated.

Dave


This is working properly, all you want to do is set the content type so
that your browser can understand it:
req.content_typ e = "text/plain"
or something like that should do it.

David
Jul 18 '05 #2
David Fraser wrote:
digidalmation wrote:
Hello all. I've been trying to get my linux server to run mod_python.
It's a Mandrake 10 linux box, and apache/mod_python are installed from
rpms.
apache2-mod_python-2.0.48_3.1.3-1mdk
apache2-2.0.48-6mdk
The rpm installed the python module as:
/usr/lib/apache2-extramodules/mod_python.so

And added a config file for apache:
/etc/httpd/conf.d/16_mod_python.c onf

The apache config files contained the following before my modifications:
<IfDefine HAVE_PYTHON>
<IfModule !mod_python.c>
LoadModule python_module extramodules/mod_python.so
</IfModule>
</IfDefine>
<IfModule mod_python.c>
</IfModule>

Now after reading the docs installed into /usr/share/doc for mod_python
and going through the directions at python.org, I've also changed the
config file to add a few lines to one of the directives:

<Directory /var/www/html>
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
</Directory>

Now when I put the url into a browser:
http://myserver.mydomain.com/mptest.py

I get a popup from the browser because it doesn't know how to handle
mptest.py, and it asks what you want to do with the file (open it with
an application, save it to disk, etc). I can choose to open the file
with a text editor, and all it shows is the text "hello world".

That's the output of the mptest.py script.... apache isn't feeding the
browser the code from the mptest.py, only the output. (Otherwise when I
open it in a text editor I'd see the entire mptest.py script.

Contents of the mptest.py script:
from mod_python import apache

def handler(req):
req.write("Hell o World!")
return apache.OK

I'm not a python developer, but have been working with Linux and Apache
for a number of years. I'm not sure where to go from here. It appears
that the script gets compiled - there is a mptest.pyc file in the
directory now. Why is it sending my browser the mptest.py file with the
stdout of the script?

Thanks in advance. Any help on this is appreciated.

Dave


This is working properly, all you want to do is set the content type so
that your browser can understand it:
req.content_typ e = "text/plain"
or something like that should do it.

David


David, you steered me in the right direction! I just added this to my
apache config file, and voila... it works.

AddType text/plain .py

Many thanks David.

Dave
Jul 18 '05 #3

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

Similar topics

1
2866
by: Rolfe | last post by:
Hi, I struggled, and got mod_python running on Apache/Win2k. Follow these instructions verbatim and you shouldn't have any trouble. These instructions are based on "http://www.modpython.org/live/current/doc-html/inst-testing.html". I've added specific information such as Windows filepaths and filenames so there's no ambiguity on what you should do. I encourage you to copy and paste to avoid typing errors. Cheers, Rolfe
1
2283
by: wolf | last post by:
i would like to briefly share my experiences with installing mod_python on a w2000 box. i must say that i believe the installation process to be unnecessarily complicated by the simple fact that the installer itself seems to be buggy -- in my case, no combination of mod_python 3.0.4, 3.1.2b and python 2.2.3, 2.3.3 ever came to completion. rather, the installer would exit -- after an initial declaration of having successfully found python...
6
3251
by: Piet | last post by:
Hi there, I cannot install mod_python v3.1.3 on either Win2k/ActivePython 2.3.2 or WinMe/Python 2.3.4. When I run the Windows installer, I get the following error message: Traceback (most recent call last): File "C:\Programme\Python23\Scripts\win32_postinstall.py", line 86, in ? apachediroptions = getApacheDirOptions() File "C:\Programme\Python23\Scripts\win32_postinstall.py", line 45, in getApacheDirOptions
3
2185
by: Rune Hansen | last post by:
I've posted this question on the mod_python mailing list but didn't get much response, so I thought I'd post it here. (My first attempt connected to an unrelated thread..sorry. Note-to-self:-must-get-more-coffee-before-posting-) It seems to me that for each path element in a URI a mod_python handler will be invoked. This applies to PythonAuthenHandler, PythonHeaderParserHandler and so on.
1
4340
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req): req.content_type = 'text/plain' req.write("Under Construction")
9
4923
by: cyberco | last post by:
And I thought this would be trivial...getting mod_python to run within apache on windows XP. ============= mod_python 3.2.8 apache 2.0.55 python2.4 winxp =============
10
1399
by: walterbyrd | last post by:
I am considering python, instead of php, for web-application development. I often see mod_python.criticisized as being borked, broken, or just plain sucking. Any truth to any of that?
10
4940
by: Vincent Delporte | last post by:
Hi I'm still a newbie when it comes to web applications, so would like some help in choosing a solution to write apps with Python: What's the difference between using running it through mod_python vs. building an application server using Python-based tools like CherryPy, Quixote, Draco, etc.? Thanks.
5
3103
by: m.banaouas | last post by:
Hi, bonjour, witch versions are suitable to use for apache & mod_python ? Can i install and use "Apache 2.2.3" & "mod_python 3.2.10" (most recent versions) without facing any known major issue ? thanks for any help.
0
8420
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
8842
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8516
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
8617
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
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
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
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
1970
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.