Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-07-2005, 02:18 PM   #1
LQ Newbie
Registered: Sep 2004
Location: izmir
Distribution: mandrake,GBL,fedora core,slackware
Posts: 26

Rep: Reputation: 15
mod_python apache configuration

Hi.I'm using Slackware 10.0 and I 've compiled httpd server( 2.0.53) from tar.gz package. My Apache server is working successfully. Then I wanted to integrate mod_python(3.1.4). I 've compiled it too.(installation completed without any error.)But I couldn't make its Apache configuration.
Is there anybody who can tell me mod_python's Apache configuration step by step? I've read the manual carefully and made the changes as it was said in the
manual. There is a testing part in the manual that you can understand whether
your mod_python module works successfully. But it didn't worked.

Here is the testing part of the mod_python manual;

2.4 Testing

Make some directory that would be visible on your web site, for example, htdocs/test.

Add the following Apache directives, which can appear in either the main server configuration file, or .htaccess. If you are going to be using the .htaccess file, you will not need the <Directory> tag below (the directory then becomes the one in which the .htaccess file is located), and you will need to make sure the AllowOverride directive applicable to this directory has at least FileInfo specified. (The default is None, which will not work.)

<Directory /some/directory/htdocs/test>
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On

(Substitute /some/directory above for something applicable to your system, usually your Apache ServerRoot)

At this time, if you made changes to the main configuration file, you will need to restart Apache in order for the changes to take effect.

Edit file in the htdocs/test directory so that is has the following lines (be careful when cutting and pasting from your browser, you may end up with incorrect indentation and a syntax error):

from mod_python import apache

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

Point your browser to the URL referring to the; you should see "Hello World!". If you didn't - refer to the troubleshooting section next.

How can I run mod_python
Old 03-08-2005, 01:06 PM   #2
Registered: Jan 2005
Distribution: Solaris, Linux Fedora Core 6
Posts: 170

Rep: Reputation: 30
Unless you have mod_python compiled into apache, you will need the following line added to the end of your other LoadModule lines:
LoadModule python_module      libexec/
and at the end of your AddModule lines:
AddModule mod_python.c
Then your little "hello world" test should run. After you have this working, you will probably want to use a more general purpose handler, for example:
        PythonHandler mod_python.publisher
There are other handlers to choose from. I am the sys admin, not the end user, so you will have to research how to use the publisher, and other, handlers. I just tried to google "mod_python.publisher" and hit a bunch of security vulnerability concerns, so use caution.
Old 03-09-2005, 05:14 AM   #3
LQ Newbie
Registered: Sep 2004
Location: izmir
Distribution: mandrake,GBL,fedora core,slackware
Posts: 26

Original Poster
Rep: Reputation: 15
I understood my mistake. I wasn't editing the file correctly. So there 've become a syntax error. Now I can see "Hello world" at my browser.

I want to add a note to wpn146. You don't need to add this line °AddModule mod_python.c ° to httpd 2.0.xx versions.And I think it will be better to putting
the complete path of "" in the first code instead of libexec.
Thanks wpn146


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
need help with mod_python tiang_ono Linux - Newbie 2 06-20-2005 08:12 PM
mod_python gaddargarson Programming 1 03-29-2005 08:45 AM
installing mod_python dominant Linux - Software 0 11-26-2004 06:19 AM
Apache and mod_python not exec python scripts fIREfox Linux - Networking 1 02-11-2003 05:54 PM
Apache with mod_python mbayeb Linux - Software 2 12-24-2002 05:24 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:10 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration