In Ubuntu to build a python operating environment, Mod_python is not rare (said MOD_SWGI is also possible, no pro-test). Use the command to install Mod_python.
Installation:
Apt-get Install Libapache2-mod-python
" Apache processes requests in stages (e.g. read requests, parse headers, check access paths, etc.). These stages can be implemented as functions called "processors" (handler). Traditionally, the "processor" was written in C and compiled into Apache's module. Mod_python provides a way to extend Apache functionality by using a Python-written Apache processor. For an exhaustive description of the Apache request process, see Apache API Notes, or see mod_python-integrating python with Apache. --excerpt from Baidu Encyclopedia
Set Mod_python:
cd/etc/apache2/mods-enabled/-S. /mods-available/mod_python.load Mod_python.load
" Ln is another very important command in Linux, its function is to create a file in another location with a non-link, the most common parameter of this command is-s, the specific use is: Ln–s source file Destination file.
When we need to use the same file in different directories, we do not need to put a file in each required directory, we just put the file in a fixed directory, and then in the other directory with the ln command link it can, do not have to repeatedly occupy disk space. Example: Ln–s/bin/less/usr/local/bin/less"-- reference
Modifying the Apache2 configuration file
cd/etc/apache2/sites-available/
sudo gedit default
On line ten you should has:
Options Indexes followsymlinks MultiViews
AllowOverride authconfig
Order Allow,deny
Allow from all
# Uncomment this directive are want to see Apache2 ' s
# Default Start Page (In/apache2-default) when do go to/
#RedirectMatch ^/$/apache2-default/
Change it to:
Options Indexes followsymlinks MultiViews
AllowOverride authconfig
Order Allow,deny
Allow from all
AddHandler Mod_python. py
Pythonhandler Mod_python.publisher
Pythondebug on
# Uncomment this directive are want to see Apache2 ' s
# Default Start Page (In/apache2-default) when do go to/
#RedirectMatch ^/$/apache2-default/
Restart Apache2 Service
/etc/init.d/apache2 restart
Test:
gedit/var/www/test.py
Content:
def index (req):
Return "Test successful";
Ubuntu Installation Mod_python Configuration Apache2