发布时间:2019-07-13 11:35:13编辑:auto阅读(2179)
下载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 之文件读写操作
51797
51504
41884
38675
33163
30142
28819
23816
23734
22099
185°
2344°
3033°
2528°
2484°
3134°
2475°
3301°
5425°
5246°