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

Unix/Linux
linux php扩展安装方法
Linux上架设支持JSP+PHP的Web服务器
FreeBSD WEB服务器架设笔记
Linux下Web服务器架设攻略
Apache配置技巧
在 Linux 上安装 PostgreSQL
文件属性控制命令chmod
解决安装Domino for Linux时配置的Web服务器无法启动的问题
在Linux下配置和安装Domino 服务器的问题
Linux下配置和安装Domino 服务器 2
Linux下配置和安装Domino 服务器 3
Linux编译内核
I810 Graphics LINUX Driver的安装
在Linux下如何使用软盘、光盘等分区
建立并安装一个定制的内核
中小型企业的Sendmail邮件服务器应用实例
Linux下 Sendmail服务器 转发功能的讲解
linux下文件解压
配置Sendmail服务器以防治垃圾邮件
配置Sendmail服务器以防治垃圾邮件 2

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-15   浏览: 69 ::
收藏到网摘: 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, 完事.