LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   mod python: What to use for PythonHandler in apache2.conf? (http://www.linuxquestions.org/questions/linux-software-2/mod-python-what-to-use-for-pythonhandler-in-apache2-conf-491627/)

BrianK 10-11-2006 09:08 PM

mod python: What to use for PythonHandler in apache2.conf?
 
I'm trying to get apache2's modpython working. I've installed mod_python & added the following lines to my apache2.conf:

AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On


Is this correct? What is mod_python.publisher? How do I know if I have it?

If I look at my apache2 error log, I see these lines every time I try to access the python script through a browser:

[Wed Oct 11 18:59:36 2006] [notice] mod_python: (Re)importing module 'mod_python.publisher'
[Wed Oct 11 18:59:36 2006] [notice] mod_python: (Re)importing module 'example1' with path set to '['/job/drqueue/python/examples ']'


... and then the page comes up as a 404. ??

BrianK 10-10-2007 05:24 PM

if anyone else comes across this same problem, here's the deal:

the above is correct - kindof.

It assumes there's some built-in python module called "publisher". As of the mod_python I just built v3.3.1, that doesn't exist. There is, however, a built-in called "testhandler" that will spit back a lot of python info, kinda like phpinfo() in php if you're familiar. Otherwise, you can just enter in the name of your script (minus the .py) to test.

So, if you make a hello world mod_python program called "hello.py" in /local/htdocs/python, the test config for apache would look like:

Code:

<Directory "/local/htdocs/python">
  AddHandler mod_python .py
  PythonHandler hello
  PythonDebug On
</Directory>

... or if you want a lot of generic python config info, change the above to:

Code:

<Directory "/local/htdocs/python">
  AddHandler mod_python .py
  PythonHandler mod_python.testhandler
  PythonDebug On
</Directory>

Either way, go to http://localhost/python/hello.py to see the output. For the former, it will should just spit out "hello world" (assuming your program is written correctly), for the latter it will spit out a giant table of info. If you get an internal server error message, something else is wrong.


All times are GMT -5. The time now is 05:03 PM.