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