![]() |
Apache doesn't recognize python code
Hi,
Currently I have php5 and apache2 running smoothly on my ubuntu hardy machine. I have started coding on python recently, so I tried to write a few small web based application on python. That is, I tried to install libapache2-mod-python. Then I wrote the following script and put it under /var/www/new-folder/hey.py PHP Code:
Any idea how to execute web based python code? |
Quote:
you need to run .py script in cgi-bin directory Regards, mark |
Quote:
|
Quote:
When u run phpinfo(); can you see mod_python in the list? to manually install mod_python 1. download latest mod_python from here http://httpd.apache.org/modules/python-download.cgi 2. install like this Code:
% tar xfz mod_python-3.3.1.tgzCode:
LoadModule python_module modules/mod_python.soregards, Mark |
Quote:
Code:
Apache/2.2.8 (Ubuntu) mod_python/3.3.1 Python/2.5.2 PHP/5.2.4-2ubuntu5.1 with Suhosin-Patch mod_wsgi/1.3Code:
LoadModule python_module /usr/lib/apache2/modules/mod_python.so |
Quote:
Code:
AddHandler mod_python .pyhttp://www.modpython.org/live/curren.../tutorial.html Regards, Mark |
Quote:
Code:
AddHandler mod_python .pyCode:
LoadModule php5_module /usr/lib/apache2/modules/libphp5.soBy the way, can't PHP Code:
BTW, yesterday I found out that my web host supports python as well. When I uploaded my python file there, when I pointed the browser to that file, it showed me the command print "hey world". That's because I didn't write it inside <? ?> like in PHP. I think running python applications is different from running php application on apache. I m really confused |
Quote:
Regards, Mark |
Quote:
|
Quote:
1. In debian/ubuntu, httpd.conf is in /etc/apache2/apache2.conf And /etc/apache2/sites-available/default 2. pls find this in /etc/apache2/sites-available/default Code:
<Directory /var/www/>To run A python script called /var/www/test.py add the following 3 lines inside <Directory /var/www/> like this Code:
<Directory /var/www/>Code:
from mod_python import apacheCode:
Hello World!Running multiple python scripts, for example, /var/python/*.py Add the followin block in /etc/apache2/sites-available/default Code:
ScriptAlias /python/ /var/python/Code:
#""" Publisher example """1. http://localhost/python/hello.py/say , you will see Code:
I am saying NOTHING2. http://localhost/python/hello.py/say?what=Wow, you will see Code:
I am saying WowRegards, Mark |
Mark,
That was a wonderful tutorial. I really appreciate it. Unfortunately, I didn't find such information anywhere. This was the best how to for creating web based hello world application. You have to write it as a how to somewhere more appropriate, so that more people can find it. Thanks a lot |
Quote:
Quote:
Regards, Mark |
| All times are GMT -5. The time now is 09:17 PM. |