search
Homephp教程php手册Windows 下 Apache 1.3 以 FastCGI 模式运行 PHP

我一直以来都是以 ISAPI 模式运行 php(做为现在的主流开发语言) 的,这种方式最大的缺点就是稳定性不好,当 php(做为现在的主流开发语言) 出错的时候,apache(Unix平台最流行的WEB服务器平台)进程也死掉了。后来看到网上关于 php(做为现在的主流开发语言) 以 Fastcgi(现在已经不多人在用了) 模式运行的介绍,其中提到的种种好处(稳定、安全、高性能)让我决定尝试一下。

不过事情远不如预计的那么顺利。Google 了无数次也没找到一篇如何在 Windows 下用 apache(Unix平台最流行的WEB服务器平台) + Fastcgi(现在已经不多人在用了) 跑 php(做为现在的主流开发语言) 的资料,iis(微软的WEB服务器平台) + Fastcgi(现在已经不多人在用了) 跑 php(做为现在的主流开发语言) 的倒是不少。其中有一篇提到 Zend 公司也推荐以 Fastcgi(现在已经不多人在用了) 模式运行 php(做为现在的主流开发语言)(http://php(做为现在的主流开发语言)lens.com/php(做为现在的主流开发语言)everywhere/fastcgi(现在已经不多人在用了)-php(做为现在的主流开发语言))。

经过几个小时的摸索,终于成功实现了 apache(Unix平台最流行的WEB服务器平台) 1.3 + Fastcgi(现在已经不多人在用了) 跑 php(做为现在的主流开发语言)

准备工作:
首先访问 http://www.fastcgi(现在已经不多人在用了).com/dist/ 下载用于 apache(Unix平台最流行的WEB服务器平台) 的 mod_fastcgi(现在已经不多人在用了)。我使用的是 mod_fastcgi(现在已经不多人在用了)-2.4.2-AP13.dll。下载后将这个文件复制到 apache(Unix平台最流行的WEB服务器平台) 的 modules 目录中。

下载 php(做为现在的主流开发语言)(我使用的 php(做为现在的主流开发语言)-5.0.4),并解压缩,根据需要修改 php(做为现在的主流开发语言).ini 文件。注意不需要从 php(做为现在的主流开发语言) 所在目录复制任何文件到 Windows 目录中。

修改配置:
然后修改 httpd.conf 文件,加入下面几行:

LoadModule fastcgi(现在已经不多人在用了)_module modules/mod_fastcgi(现在已经不多人在用了)-2.4.2-AP13.dll
ScriptAlias /fcgi(现在已经不多人在用了)-php(做为现在的主流开发语言)5/ "d:/usr/local/php(做为现在的主流开发语言)-5.0.4/"
Fastcgi(现在已经不多人在用了)Server "d:/usr/local/php(做为现在的主流开发语言)-5.0.4/php(做为现在的主流开发语言)-cgi(现在已经不多人在用了).exe" -processes 3
# 说明:此处的 -processes 3 表示启动三个 php(做为现在的主流开发语言)-cgi(现在已经不多人在用了).exe 进程,
# 关于 Fastcgi(现在已经不多人在用了)Server 的详细参数请参考 Fastcgi(现在已经不多人在用了) 文档。
AddType application/x-httpd-fastphp(做为现在的主流开发语言)5 .php(做为现在的主流开发语言)
Action application/x-httpd-fastphp(做为现在的主流开发语言)5 "/fcgi(现在已经不多人在用了)-php(做为现在的主流开发语言)5/php(做为现在的主流开发语言)-cgi(现在已经不多人在用了).exe"
# 说明:根据你的 php(做为现在的主流开发语言) 文件所在位置修改上面两处黑体字。

修改完成后,重新启动 apache(Unix平台最流行的WEB服务器平台) 即可。

常见问题:
根据我的多次试验,最容易出现的几个问题主要都是由路径引起的。因此首先检查 php(做为现在的主流开发语言).ini 和 httpd.conf 文件中的所有路径是否正确。其次就是如果系统中以前安装过 php(做为现在的主流开发语言),那么要将 C:Windowsphp(做为现在的主流开发语言).ini 改名或删除。

其次还要检查 php(做为现在的主流开发语言) 文件所在目录是否有足够的权限(我都是设置为 Everyone - 完全控制,反正开发用机不用考虑那么多安全限制)。

Fastcgi(现在已经不多人在用了) 模式运行 php(做为现在的主流开发语言) 的优点:
以 Fastcgi(现在已经不多人在用了) 模式运行 php(做为现在的主流开发语言) 有几个主要的好处。首先就是 php(做为现在的主流开发语言) 出错的时候不会搞垮 apache(Unix平台最流行的WEB服务器平台),只是 php(做为现在的主流开发语言) 自己的进程当掉(但 Fastcgi(现在已经不多人在用了) 会立即重新启动一个新 php(做为现在的主流开发语言) 进程来代替当掉的进程)。其次 Fastcgi(现在已经不多人在用了) 模式运行 php(做为现在的主流开发语言) 比 ISAPI 模式性能更好(我本来用 apache(Unix平台最流行的WEB服务器平台)Bench 进行了测试,但忘了保存结果,大家有兴趣可以自己测试)。

最后,就是可以同时运行 php(做为现在的主流开发语言)5 和 php(做为现在的主流开发语言)4。参考下面的配置文件,分别建立了两个虚拟主机,其中一个使用 php(做为现在的主流开发语言)5,另一个使用 php(做为现在的主流开发语言)4。

LoadModule fastcgi(现在已经不多人在用了)_module modules/mod_fastcgi(现在已经不多人在用了)-2.4.2-AP13.dll

ScriptAlias /fcgi(现在已经不多人在用了)-php(做为现在的主流开发语言)5/ "d:/usr/local/php(做为现在的主流开发语言)-5.0.4/"
Fastcgi(现在已经不多人在用了)Server "d:/usr/local/php(做为现在的主流开发语言)-5.0.4/php(做为现在的主流开发语言)-cgi(现在已经不多人在用了).exe" -processes 3
ScriptAlias /fcgi(现在已经不多人在用了)-php(做为现在的主流开发语言)4/ "d:/usr/local/php(做为现在的主流开发语言)-4.3.11/"
Fastcgi(现在已经不多人在用了)Server "d:/usr/local/php(做为现在的主流开发语言)-4.3.11/php(做为现在的主流开发语言).exe"

Listen 80
NameVirtualHost *:80

DocumentRoot d:/www
Options Indexes FollowSymlinks MultiViews
ServerName php(做为现在的主流开发语言)5.localhost

AddType application/x-httpd-fastphp(做为现在的主流开发语言)5 .php(做为现在的主流开发语言)
Action application/x-httpd-fastphp(做为现在的主流开发语言)5 "/fcgi(现在已经不多人在用了)-php(做为现在的主流开发语言)5/php(做为现在的主流开发语言)-cgi(现在已经不多人在用了).exe"


IndexOptions FancyIndexing FoldersFirst
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all

Listen 8080
NameVirtualHost *:8080


DocumentRoot d:/www
Options Indexes FollowSymlinks MultiViews
ServerName php(做为现在的主流开发语言)4.localhost

AddType application/x-httpd-fastphp(做为现在的主流开发语言)4 .php(做为现在的主流开发语言)
Action application/x-httpd-fastphp(做为现在的主流开发语言)4 "/fcgi(现在已经不多人在用了)-php(做为现在的主流开发语言)4/php(做为现在的主流开发语言).exe"



Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.