当前位置: 首页 > 图文教程 > 操作系统 > Unix/Linux > Ubuntu 8.04中使用fast-cgi搭建Apache2+PHP5环境

Unix/Linux
samba的配置[转载]
内核上的dns服务应答可以工作了
a bug of ng_vlan?
安装discuz论坛过程中出现不能识别preg_replace()函数的问题!
DHCP配置
一个很简单但是最常用的SED例子:UNIXDOS文本格式转换
在 linux 上架设 FreeBSD CVSup mirror
CICS FOR WINDOWS
FreeBSD光盘运行版的制作过程
初识FreeBSD
自定义C shell
Linux真的比Windows安全?
ipf+ipnat+ipfw建立带流量控制的透明网关
8139C+ 不能被正确识别网线状态的修订
Reinstall the boot manager.
备份qmail的一个脚本
Open the sound volume
FreeBSD-5.2下安装ORACLE9i手记
bsd 分支表
DNS傻瓜书

Unix/Linux 中的 Ubuntu 8.04中使用fast-cgi搭建Apache2+PHP5环境


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-15   浏览: 133 ::
收藏到网摘: n/a

在Ubuntu中搭建一般的LAMP环境实在是太简单的一件事, 只需要

$sudo apt-get install apache2 php5 mysql-server libapache2-mod-php5

就好了(差不多, 如果没记错的话).

然而, 这样搭建出来的LAMP环境, PHP是通过Apache2的mod执行的, 这也就是软件包libapache2-mod-php5的作用. 通过mod执行的PHP有速度快, 方便等诸多优势. 不过现在我就是想要它通过Fastcgi执行. 别问为什麽.

找了好多资料, 奇怪怎麽就没人能说清楚, 真是..... 只好自己总结了

----------------------cut here----------

首先, 删除libapache2-mod-php5, 因为没用了.$sudo a2dismod php5
$sudo apt-get remove libapache2-mod-php5

安装cgi版的php(自己会支持fcgi的)和apache2的action模块
$sudo apt-get install php5-cgi
$sudo a2enmod actions

新建目录, 把安装的php5-cgi扔过去

$sudo mkdir /usr/local/php5-fcgi
$sudo mkdir /usr/local/php5-fcgi/bin
$sudo cp /usr/bin/php5-cgi /usr/local/php5-fcgi/bin/

下面关键了, 总是出错的就是这了

在你的虚拟主机配置(sites-enabled那里)文件,

之内, 其他标签之外添加这些内容:

ScriptAlias /fcgi-bin/ "/usr/local/php5-fcgi/bin/"
Action php-fastcgi /fcgi-bin/php5-cgi
AddHandler php-fastcgi .php
AddType application/x-httpd-php .php

Options FollowSymLinks ExecCGI


然后重启apache2, 完事.