Comments on Embedding Python In Apache2 With mod_python (Debian Etch)
Embedding Python In Apache2 With mod_python (Debian Etch) This tutorial shows how to install and use mod_python on a Debian Etch server with Apache2. mod_python is an Apache module that embeds the Python interpreter within the server. It allows you to write web-based applications in Python that will run many times faster than traditional CGI and will have access to advanced features such as ability to retain database connections and other data between hits and access to Apache internals.
9 Comment(s)
Comments
Probably better than editing /etc/apache2/sites-available/default is global activation for mod_python. It should work independently where you store yours sites.
So if you decide that e.g. you want your user to put sites in /home/user_login/public_html you just need to activate userdir mode. They will can use python in scripts automaticaly
In /etc/apache2/mods-available/ create file mod_python.conf with this content (if you want Publisher Handler):
<IfModule mod_python.c> AddHandler mod_python .py PythonHandler mod_python.publisher PythonDebug On </IfModule>
or this (if you want PSP Handler):
<IfModule mod_python.c> AddHandler mod_python .psp PythonHandler mod_python.psp PythonDebug On </IfModule>
Then you need to activate mod_python by: a2enmo mod_python. If it was already activated, deactivate it with a2dismod first or create symlink in /etc/apache2/mods-enabled/ to mod_python.conf by hand.
Or add this to enable both extensions:
<IfModule mod_python.c> AddHandler mod_python .py .psp PythonHandler mod_python.publisher | .py PythonHandler mod_python.psp | .psp </IfModule>
Hi, im new with apache on linux and i was wondering about the IfModule posted above, i understand it goes into
/etc/apache2/mods-enabled/mod_python.conf
but, how about if i want to enable it for just one host? should i place it just like that into
/etc/apache2/sites-available/default
or should i put it inside the directory tags like this
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .py .psp
PythonHandler mod_python.publisher | .py
PythonHandler mod_python.psp | .psp
PythonDebug On
</Directory>
thanks in advance, im a little confused here
Thank you!
After 2 days I try launch python script, I found this, I never knew! Great! You help me really!
You all are my heros.
I solved the problem with python 2.5.6, mod_python 3.3.1 and apache 2. Got both psp and py pages displaying.
I enabled Python this way and it's working, but now i get the output twice. When using the <Directory> syntax everything was fine but my users can't use python automagically.
any ideas?
rgds
Exactly what i needed! thanks!!!
Hi, In my case I can't add both .py and .psp. I added directory for .py and then directory for .psp. Can I use them both?
Users should be aware that mod_python has been deprecated for some time; use mod_wsgi instead.