I encountered some problems while reading the mod_python installation documentation. Now I have solved them. I 'd like to share with you.
My system is Ubuntu 9.04. Use apt-get to install Apache and mod_python
Here is the Chinese Document of mod_python for my reference.
In section 2.3.2 configure Apache, the content in the/etc/apache2/mod-available/python. Load file is
LoadModule python_module /usr/lib/apache2/modules/mod_python.so
Create a python. conf file under the/etc/apache2/mod-available/directory to configure the python-related application information.
<Directory/var/wwwt>
Addhandler mod_python. py
Pythonhandler mptest
Pythondebug on
Addtype text/html; Qs = 1.0. py
Addtype text/html; Qs = 0.9. html
Addtype text/html; Qs = 0.8. txt
</Directory>
The last three lines are important. For example, when I use Firefox to browse the file, I cannot parse the file but directly download the file.
Here I refer to 2 articles to solve 1 2
Addtype text/html; Qs = 1.0. py
Addtype text/html; Qs = 0.9. html
Addtype text/html; Qs = 0.8. txt
Then use the ln command to create a connection to the two files to/etc/apache2/mod-enabled /.
Run the/etc/init. d/apache2 restart command to restart Apache.
Create a file mytest. py under/var/www /.
Content is
From mod_python import Apache
Def handler (req ):
Req. Write ("Hello world! ")
Return Apache. OK
Test it in the browser. If you see hello World! It is successful.