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

Unix/Linux
查看linux 下已经安装的软件包信息
linux 系统中软件raid 配置方法
linux 下MySQL服务器的启动与停止
linux 系统下FTP服务器配置方法
Linux系统下如何挂载U盘,硬盘,光驱
linux 系统下DHCP服务器 配置方法
Linux系统下软件的安装与卸载
在Fedora 9中启用ext4文件系统的方法
linux下挂载(mount)光盘镜像文件、移动硬盘、U盘、Windows网络共享和NFS网络共享
Linux查看文件夹大小的命令
LINUX系统grub常见错误分析
llinux fdisk分区工具 使用方法
linux 系统telnet乱码
rhythmbox 乱码的解决方法
linux单网卡绑定多ip
tar.gz 和tar.bz2 详细解释
linux学习笔记
linux系统rpm安装包详解
linux 服务器常用维护命令
出现The file /boot/grub/stage1 not read cor 解决办法

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


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