Ubuntu Installation Mod_python Configuration Apache2

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.