发布时间:2019-07-13 11:35:13编辑:auto阅读(2208)
下载mod_python 源码包
git clone https://github.com/grisha/mod_python
编译安装
cd mod_python
#./configure --help 查看编译的参数
yum -y install httpd-devel
./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python
make
make install_py_lib
sudo make install
make test #测试,可以略过
修改apache 配置文件
vim conf.d/python.conf
LoadModule python_module modules/mod_python.so
Alias /py /var/www/html/py
<Directory /var/www/html/py>
AddHandler mod_python .py
PythonHandler mptest
PythonDebug On
</Directory>
编写一个测试文件
vim /var/www/html/py/mptest.py
from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.write("Hello World!")
return apache.OK
保存退出
重启apache
返回"hello world!" 表示加载成功
上一篇: Python 模版(二)
下一篇: Python 之文件读写操作
51938
51730
42031
38873
33360
30325
28969
23984
23900
22261
413°
2602°
3280°
2731°
2719°
3468°
2681°
3511°
5799°
5579°