473,385 Members | 1,769 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,385 software developers and data experts.

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.conf

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("Hello 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 2894
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.conf

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("Hello 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_type = "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.conf

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("Hello 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_type = "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
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...
1
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...
6
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...
3
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....
1
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):...
9
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
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
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...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.