LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-11-2003, 12:53 PM   #1
fIREfox
LQ Newbie
 
Registered: Aug 2002
Location: UK
Distribution: Gentoo
Posts: 7

Rep: Reputation: 0
Apache and mod_python not exec python scripts


My problem is that apache is displaying the source code of my python script [which just says Hello World] rather than giving it to the python interpreter to execute. Running the script in a shell produces the expected.

Using Gentoo 1.4, Apache 1.3.27, Python 2.2.2 and mod_python 2.7.8

Im sure that my problem is apache config related, but Ill explain my situation in full anyhow.

All relative programs have been emerged from the latest Gentoo portage tree.
I am able to run perl scripts fine in the cgi-bin and php scripts from the public_html directory. The python script im trying to run is chmodded 755 and *does* include the #!/usr/bin/python on the 1st line

I have added '-D PYTHON' to the startup script flags and when the server is started, the following is noted in error_log, so I gather than apache and python are happy

Quote:
Apache/1.3.27 (Unix) (Gentoo/Linux) mod_python/2.7.8 Python/2.2.2 PHP/4.3.0 configured -- resuming normal operations
/etc/apache/apache.conf includes the following:

Quote:
<IfDefine PYTHON>
LoadModule python_module extramodules/mod_python.so
</IfDefine>
and
Quote:
<IfDefine PYTHON>
AddModule mod_python.c
</IfDefine>
This file subsequently calls for the folloing configs:

Quote:
Include conf/commonapache.conf
Include conf/addon-modules/mod_python.conf
mod_python.conf mearly has the following...

Quote:
<IfModule mod_python.c>
AddHandler python-program .py
</IfModule>
commonapache.conf is somewhat longwinded ... but I have added the following while playing to try and get the scripts rendering. Using a little logic I added the following in the same section where the relevant .cgi and .php lines are:

Quote:
AddType text/x-script.python .py
AddHandler python-program .py
Does anyone have any ideas / spot any obvious mistakes? Note that I have followed the gentoo ebuild script and docs to the letter [from what I can see :P] and the only addition I have made are those last 2 lines to commonapache.conf.

Thanks in advance.

Last edited by fIREfox; 02-11-2003 at 12:54 PM.
 
Old 02-11-2003, 05:54 PM   #2
fIREfox
LQ Newbie
 
Registered: Aug 2002
Location: UK
Distribution: Gentoo
Posts: 7

Original Poster
Rep: Reputation: 0
With some more playing I have managed to anwser my own question

As I thought it was an apache config issue, during my previous attempts I added the Python Handlers to exsisting directories, only for apache to complain about a bad config, but I managed to fix it by creating /var/www/public_html/python and within this directory I placed the handlers as mentioned in the URL below.

http://www.modpython.org/live/mod_py...t-testing.html
 
  


Reply


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
exec bash scripts from Glade/GTK? HELP! cho Programming 1 07-04-2005 08:01 AM
mod_python apache configuration gaddargarson Programming 2 03-09-2005 05:14 AM
Python EXEC Statement ranger_nemo Programming 3 07-24-2003 08:31 PM
compiling Python scripts lex1dr Linux - Software 1 06-16-2003 04:24 PM
Apache with mod_python mbayeb Linux - Software 2 12-24-2002 05:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:15 AM.

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