Apache Mod_python Installation

Source: Internet
Author: User

Environment : Linux 2.6.32-431.23.3.el6.i686

1. Install Python
wget http://www.python.org/ftp/python/2.7.1/Python-2.7.1.tgz
tar zxf python-2.7. 1. tgz
./configure--prefix=/usr/local/services/python-2.7. 1
Make
Make Install

2. Installing httpd (Apache)

http//down1.chinaunix.net/distfiles/httpd-2.0.59.tar.bz2
TarJXF httpd-2.0. -.Tar. bz2
./configure--prefix=/usr/local/services/httpd-2.0. ---enable-rewrite--enable-so
Make
MakeInstall

3, install MOD_PYTHON
wget  http:< Span style= "color: #008000;" >// archive.apache.org/dist/httpd/modpython/mod_python-3.3.0b.tgz mod _python-3.3.0b.tgz
tar  zxf 
./configure \ 
--prefix=/usr/local/services/mod_python- 3.3 . 0b \ 
--with-apxs=/usr/local/services/httpd-2.0 . 59 /bin/apxs \ 
--with-python=/usr/local/services/python-< Span style= "color: #800080;" >2.7 . 1 /bin/python2. 7
make
make  install


error occurred: Mod_python only works with Apache 2.
Be sure to look closely at the Help document (./configure--help) When compiling incorrectly, which can save a lot of time

4. Configuring Apache (httpd.conf)

4.1. Load Moduleloadmodule python_module modules/mod_python.so
# (80 already occupied)
Listen80804.2. Configure handle Python add SetHandler mod_ under the root directory (<directory "/usr/local/services/httpd-2.0.59/htdocs" >) Python
Pythonhandler Test
Pythondebug On4.3, restart httpd/usr/local/services/httpd-2.0. -/bin/apachectl restart

5. Verification

5.1, inadd test.py script under/usr/local/services/httpd-2.0.59/htdocs fromMod_pythonImportApache
defHandler (req):
Req.write ("Hello world!")
returnApache. OK5.2, browser input: http://192.168.44.129: 8080/testDisplay:

Apache Mod_python Installation

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.