473,769 Members | 6,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with setting up mod_python and Apache

Hi
I have set up httpd.conf according to installation and configuration
instructions in the mod_python documentation. Yet when I enter the following
URL http://localhost/test.py all I get is an Apache view of my htdocs
directory. They if I click on test.py and open file dialog pops up. If I
give the file a cgi extension and enter the following URL
http://locathost/test.cgi it runs fine. I just can't figure out what I am
doing wrong.

--
Best Regards
John
Jul 18 '05 #1
6 2180
"John Dean" <jo**@rygannon. com> wrote in message
news:3f******** *************@l ovejoy.zen.co.u k...
I have set up httpd.conf according to installation and configuration
instructions in the mod_python documentation. Yet when I enter the following URL http://localhost/test.py all I get is an Apache view of my htdocs
directory. They if I click on test.py and open file dialog pops up. If I
give the file a cgi extension and enter the following URL
http://locathost/test.cgi it runs fine. I just can't figure out what I am
doing wrong.


Sounds like a configuration problem. Can you post the relevant lines from
your httpd.conf file? Are you trying to write handlers or are you using the
publisher module?

Dave
Jul 18 '05 #2
Quoting John Dean:

Here are the lines in my httpd.conf
LoadModule python_module /usr/lib/apache/mod_python.so

AddModule mod_python.c

<Directory "srv/www/htdocs">
.....
.....

Addhandler python-program .py
PythonHandler test


Looks right to me. Have you verified that:
a) you are editing the right httpd.conf (hey, it happens...)
b) you are affecting the directory you think you are (do other apache
directives work properly?)

Once things are working, you may also want to read up on and consider adding
this:
PythonInterpPer Directory on
(hint: otherwise, if you have a test.py in another directory, you will get
bizarre results)

Good luck,
Dave

PS - Please keep replies to the list for the benefit of others. =)
Jul 18 '05 #3
Hi Dave

I have fixed my problem with mod_python. I have one small problem left to
sort out. If I enter the URL http://localhost Apache just displays the
contents of the htdocs directory, but if I enter the URL
http://localhost/test.py everything works as it should. I guess this is
somewhat off topic since it appears to be an Apache configuration problem so
I hope you don't mind me asking you for your opinion on c.l.p.

BTW What I am trying to do is to move away from PHP. Since I use Python as
my primary scripting language for just about everything where you would use
a scripting language, it seems to me to be a reasonable idea to use Python
to provide dyanamic content for the web sites I look after.

--
Best Regards
John
Jul 18 '05 #4
"John Dean" <jo**@rygannon. com> wrote in message
news:3f******** *************@l ovejoy.zen.co.u k...
Hi Dave

I have fixed my problem with mod_python. I have one small problem left to
sort out. If I enter the URL http://localhost Apache just displays the
contents of the htdocs directory, but if I enter the URL
http://localhost/test.py everything works as it should. I guess this is
somewhat off topic since it appears to be an Apache configuration problem so I hope you don't mind me asking you for your opinion on c.l.p.
Yes, you should condition your server not to give you a directory listing
when the default documents aren't found - this is big-time information
leakage, and gives an attacker leverage to start finding vulnerabilities .
So, beofre you go into production, fix that! The config command you need is
something like

DirectoryIndex index.htm index.html index.html.var index.php

You might want to include index.py there too!

How did you solve your mod_python problem, by the way?
BTW What I am trying to do is to move away from PHP. Since I use Python as
my primary scripting language for just about everything where you would use a scripting language, it seems to me to be a reasonable idea to use Python
to provide dyanamic content for the web sites I look after.

Nice. Just try to resist the temptation to replace working PHP with working
Python - nobody's paying you for that! Translate to Python when upgrading,
or for new functionality.

still-from-Yorkshire-ly y'rs - steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/

Jul 18 '05 #5
Hi Steve
Thank you very much for your reply
Funnily enough I sorted out Apache problem before reading you post. Thanks
all the same.
I have mod_python working like a dream. So now in to the hard part. I hope
you won't mind if I explain. The project I am working on, Rekall, contains
serveral WSYWIG designers. Two of these designers are of particular interest
for what I have in mind - the Form and Report Designers. Form and Report
definitions are stored in XML format either as a file in the file system or
in a SQL Database. The basic idea is to load a string object with the form
or report definition. Then using Pythons XML DOM module build a HTML
document plus the required SQL query string(s). If it is a form then we'll
will need to build both the HTML data input form and the backend form
processor. I guess this will need a publisher handler. I expect Reports to
be a lot easier, but since I am talking about several report output during a
single session I suppose I will need to get my head around dynamic handlers.
Now that's frightening

--
Best Regards
John
Jul 18 '05 #6
"John Dean" <jo**@rygannon. com> wrote in message
news:3f******** *************@l ovejoy.zen.co.u k...
I have fixed my problem with mod_python. I have one small problem left to
sort out. If I enter the URL http://localhost Apache just displays the
contents of the htdocs directory, but if I enter the URL
http://localhost/test.py everything works as it should. I guess this is
somewhat off topic since it appears to be an Apache configuration problem so I hope you don't mind me asking you for your opinion on c.l.p.
Well, I get around this problem by adding "index.py" to the DirectoryIndex
directive. I use a modified version of the publisher module that comes with
mod_python that handles this and related special cases. Here's the change
that I make, if you're interested:

< if not _req.subprocess _env.has_key("P ATH_INFO"):
< raise apache.SERVER_R ETURN, apache.HTTP_NOT _FOUND
<
< func_path = _req.subprocess _env["PATH_INFO"][1:] # skip fist /
< func_path = string.replace( func_path, "/", ".")
--- if _req.subprocess _env.has_key("P ATH_INFO"):
func_path = _req.subprocess _env["PATH_INFO"][1:] # skip first /
func_path = string.replace( func_path, "/", ".")

# If no function is specified, assume "default".
if not len(func_path): func_path = "default"
else:
# If no module is specified either, assume "index".
func_path = "default"
module_name = "index"
This has the result that "index" is always the default module, and "default"
is the function within that module that gets called if no function is
explicitly specified on the URL. This works like a charm.
BTW What I am trying to do is to move away from PHP. Since I use Python as
my primary scripting language for just about everything where you would use a scripting language, it seems to me to be a reasonable idea to use Python
to provide dyanamic content for the web sites I look after.


I did the same thing myself last year, after writing PHP for a couple of
years. mod_python definitely makes Python a worthy substitute for writing
Apache modules. The main drawbacks from my experience are the lack of
built-in session handling and more sophisticated parameter passing (ie.
PHP's ability to serialize hashes from a form submission). But I'm a little
dated now, I'm still using mod_python 2 / apache 1.3 ...

Have fun,
Dave

Jul 18 '05 #7

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

Similar topics

1
2870
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
2
2923
by: digidalmation | last post by:
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:
0
1607
by: Julien Cigar | last post by:
Hello, I'm using mod_python 3.1.3 with Apache 2.0.54 on a Debian box with the publisher handler and the Clearsilver template engine, and from time to time apache returns an 500 error code (Internal Server Error). Apache errog.log file looks like : PythonHandler mod_python.publisher: Traceback (most recent call last): PythonHandler
2
2081
by: Robert J. Hansen | last post by:
I'm not entirely certain comp.lang.python is the proper newsgroup for mod_python questions, but "comp.lang.python.web" doesn't seem to exist, so... my apologies in advance if this is considered off-topic. I'm attempting to get mod_python 3.1.4/python 2.4.1 working on Apache 2.0.54 running under OS X. Apache was compiled from source with a simple /configure --enable-so --with-mpm=worker
2
3310
by: exhuma.twn | last post by:
Hi again, as soon as I try to make use of the "session" object inside a psp-template file, I get the following error: Mod_python error: "PythonHandler mod_python.publisher" Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
4
4714
by: John Salerno | last post by:
I get this internal error message when I try to access a PSP page: "Invalid command 'PythonHandler', perhaps mis-spelled or defined by a module not included in the server configuration" So it seems that mod_python is not fully configured yet to handled PSP pages. When I check the installed Apache handlers, there is an entry called "mod_python .psp" where the first term is the handler and the second is the extension. I also tried adding...
4
4671
by: Gaurav Agarwal | last post by:
Hi, Am using WAMP5 and python 2.4.3. I tried to install mod_python 3.2.5 for python2.4. When i tried starting wamp, Firstly there was no error message in the apache error log. I saw error message in windows event viewer : "The Apache service named Apache.exe reported the following error: before the error.log file could be opened.
7
1822
by: Ben Finney | last post by:
Howdy all, I'm working on a web application that is starting to gain a lot of back-end code written in Python. However, all the current interface code is written in legacy PHP. I'd like to slowly introduce new features as Python WSGI programs. Is it possible to write a Python WSGI program that talks to a PHP program as its "back end"? Where can I find out how to do this, preferably with examples?
3
4940
by: joe jacob | last post by:
I configured apache to execute python scripts using mod_python handler. I followed below mentioned steps to configure apache. 1. In http.conf I added <Directory "D:/softwares/Apache2.2/htdocs"> AddHandler mod_python .py PythonHandler mptest PythonDebug On </Directory>
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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
9993
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
9863
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...
0
8870
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...
1
7406
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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
3561
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.