fedora安装mod_python

3.1 Installing mod_python


To install mod_python, we simply run:

yum install mod_python

3.2 Configuring Apache


Now we must configure Apache so that it can handle Python files. There are
two ways of doing so. The first (and default) one is to use the Publisher Handler. It allows you to write pure Python
scripts with the extension .py that will be interpreted by Apache. The second
way is the PSP Handler. PSP stands for Python
Server Pages. It allows you to embed Python code directly in HTML code, similar
to PHP. PSP files have the extension .psp.

3.2.1 The Publisher Handler


To enable the Publisher Handler, we must edit the mod_python configuration
which you can find in /etc/httpd/conf.d/python.conf. This file contains many
examples - we make a backup of it and create that file again from scratch. I‘m
using the default Fedora/CentOS document root /var/www/html here in the<Directory> directive - adjust this to your
needs. The important lines are AddHandler mod_python
.py and PythonHandler
mod_python.publisher:

cp /etc/httpd/conf.d/python.conf
/etc/httpd/conf.d/python.conf_orig
cat /dev/null >
/etc/httpd/conf.d/python.conf
vi /etc/httpd/conf.d/python.conf




LoadModule python_module modules/mod_python.so

<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
</Directory>



Please note: if you use ISPConfig (from version 2.2.24 on)
on the server, please leave out the <Directory ...>...</Directory>
part in the above file since that would enable mod_python globally for the
directory in question. In ISPConfig you can enable mod_python on a per-website
basis instead which gives you more control whether a website can use mod_python
or not.

Restart Apache afterwards:

/etc/init.d/httpd restart

Now we create a little Python test script (e.g. /var/www/html/test.py) with pure Python code in it...

vi /var/www/html/test.py




def index(req):
return "Test successful";

... and call it in a browser (e.g. http://192.168.0.100/test.py). If all goes well, it should
display Test successful in your
browser.

3.2.2 The PSP Handler


To enable the PSP Handler, we must edit the mod_python configuration which
you can find in /etc/httpd/conf.d/python.conf.
This file contains many examples - we make a backup of it and create that file
again from scratch. I‘m using the default Fedora/CentOS document root /var/www/html here in the <Directory>directive - adjust this to your needs.
The important lines are AddHandler mod_python
.py and PythonHandler
mod_python.psp:

cp /etc/httpd/conf.d/python.conf
/etc/httpd/conf.d/python.conf_orig
cat /dev/null >
/etc/httpd/conf.d/python.conf
vi /etc/httpd/conf.d/python.conf




LoadModule python_module modules/mod_python.so

<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddHandler mod_python .psp
PythonHandler mod_python.psp
PythonDebug On
</Directory>



Please note: if you use ISPConfig (from version
2.2.24 on) on the server, please leave out the <Directory
...>...</Directory> part in the above file since that would enable
mod_python globally for the directory in question. In ISPConfig you can enable
mod_python on a per-website basis instead which gives you more control whether a
website can use mod_python or not. Also note that ISPConfig does not support the
PSP Handler - it uses the Publisher Handler.

Restart Apache afterwards:

/etc/init.d/httpd restart

Now we create a little PSP test script (e.g. /var/www/html/test.psp) with HTML and Python code in
it...

vi /var/www/html/test.psp




<html>
<body>
<h1><% req.write("Hello!") %></h1>
</body>
</html>

... and call it in a browser (e.g. http://192.168.0.100/test.psp). If all goes well, it
should display Hello! in your
browser.

fedora安装mod_python,布布扣,bubuko.com

时间: 2024-10-04 01:15:02

fedora安装mod_python的相关文章

[Fedora] 安装时遇到的问题汇总

一.普通用户无法使用 sudo 操作 [[email protected] ]$ vim /etc/sudoers在 增加一行 root ALL=ALL ALL+user ALL(ALL) ALL 二.64 位 Fedora 安装 32 位兼容库 yum install glibc libstdc++ libgcc libX11.i686 libXext.i686 libao.i686 alsa-lib.i686 三.解决 Kernel 执行 make menuconfig 报错问题 http:

Fedora 安装 NTP

一.列出ntp软件包 yum list ntp 二.安装ntp软件包 yum install ntp 三.修改配置文件 vi /etc/ntp.conf 四.启动ntp service ntpd start 五.关闭ntp service ntpd stop 六.查看状态 ntpq -p 七.设置开机启动 1. 获取chkconfig 命令的帮助 chkconfig --help 八.查看123端口是否打开 netstat -tlunp 九.查看是否和ntp服务器连接上 ntpstat Fedo

fedora 安装新字体 courier new xxx

fedora安装新字体 1.将windows字体拷贝到/usr/share/fonts/truetype下面,文件夹名字可以随便起 cp /media/c/WINDOWS/Fonts/* /usr/share/fonts/truetype/ 默认字体权限应该是755,如果不是的话,手动更改下 chmod 755 * 2.在/usr/share/fonts/truetype下面运行 mkfontscale mkfontdir 3.运行fc-cache -fv,刷新字体缓存. 现在就一切ok了

fedora 安装 pidgin-lwqq

由于 腾讯自带的linux for  qq 已经无法登陆,于是详尽各种办法在fedora 上安装 qq ,但均以失败高中,于是使用了几天web qq 但终于无法忍受,于是有研究起来了 pidgin-lwqq 终于安装成功,上图直接 可以首发图片 以下直接上安装步骤 1. 首先安装 pidgin 1 sudo yum install pidgin 成功后 需要添加 pindgin-lwqq  以支持 qq协议 先上两个地址 非常详细 pidgin-lwqq安装文档 lwqq 安装文档 其中 pid

Ubuntu 安装mod_python配置Apache2

在Ubuntu上搭建Python运行环境,mod_python是不可少的(据说mod_swgi也是可以的,没有亲测).使用命令安装mod_python. 安装: apt-get install libapache2-mod-python “Apache分阶段的处理请求(比方说:读取请求,解析header, 检查存取路径,等等).这些阶段能被称为"处理器"(handler)的函数实现.传统上, "处理器"是由C语言编写,并编译成Apache的模块.Mod_python

fedora安装新字体!

1.在/usr/share/fonts下面新建文件夹,如fonts并拷贝需要的字体文件 2.cd /usr/share/fonts/fonts mkfontscale mkfontdir 3.fc-cache -fv fedora安装新字体!

解决Fedora安装Virtualbox后无法运行:/etc/init.d/vboxdrv setup

解决Fedora安装Virtualbox后无法运行:/etc/init.d/vboxdrv setup 在Fedora下安装了Virtualbox,发现运行时出现以下问题: Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please

Fedora安装Snapd和Snap软件包

导读 Snappy包管理器是一个跨发行版的包管理器.它最初是为Ubuntu系统构建的,但现在其他主要的Linux发行版( Fedora, Linux Mint, RHEL, OpenSUSE,Arch Linux等)都能使用Snappy.与RPM和Deb不同的是,Snap软件包可以安装并运行在所有Linux发行版. Snap包是一个经过压缩的文件系统,由宿主机操作系统动态挂载到/snap目录.其携带的元数据由snapd处理,然后snapd为其创建一个安全的沙盒环境.Snap软件包的优势在于它是一

Fedora安装VirtualBox时出现错误Kernel driver not installed (rc=-1908)的解决办法

新建虚拟机后启动时出现如下错误: Kernel driver not installed (rc=-1908) The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Re-setup the kernel module by executing '/etc/init.d/vboxdrv setup' as root.