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

Unix/Linux
linux查看内存的大小
在linux下写的代码,用的是utf-8,结果拿到XP下运行的时候,所有的中文都成乱码
linux su和sudo命令的区别
linux cron 下的定时执行工具使用技巧
linux 查找进程及终止进程操作的相关命令
redhat linux 安装 gcc编译器
Linux Mplayer播放各种格式的电影
一起回顾一下linux常用命令
Linux 网站项目发布要做哪些配置
linux SSH配合SecureCRT的密匙完美使用方法
GD 编译出错解决方法
Facebook Open Platform编译FAQ
Linux 系统硬盘 优化
linux 挂载详解
linux crontab定时命令
Linux 系统中确保访问三级域名畅通的方法
Linux 特权帐号VS普通帐号
确保Linux系统安全的前提条件 漏洞防护
Linux 监视系统资源使用率
Red Hat Linux上使用BIND建立DNS服务器

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


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