diaoyudao 发表于 2018-11-22 12:30:52

apache mod_python 安装

  下载mod_python源码包
  gitclonehttps://github.com/grisha/mod_python
  编译安装
  cd   mod_python
  #./configure--help    查看编译的参数
  yum-y installhttpd-devel
  ./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python
  make
  make   install_py_lib
  sudo make install
  make test   #测试,可以略过
  

  修改apache 配置文件
  vimconf.d/python.conf
  LoadModule python_module modules/mod_python.so
  Alias /py /var/www/html/py
  
  AddHandler mod_python .py
  PythonHandler mptest
  PythonDebug On
  
  编写一个测试文件
  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
  访问http://host/py/mptest.py
  返回"hello world!"表示加载成功



页: [1]
查看完整版本: apache mod_python 安装