Home  >  Article  >  Backend Development  >  Apache 1.3 running PHP in FastCGI mode under Windows_PHP tutorial

Apache 1.3 running PHP in FastCGI mode under Windows_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:33:52923browse

我一直以来都是以 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服务器平台) 即可。

Frequently asked questions:
According to my many experiments, the most common problems are mainly caused by paths. So first check whether all paths in the php(as the current mainstream development language).ini and httpd.conf files are correct. The second is that if php(as the current mainstream development language) has been installed in the system before, then you need to rename C:Windowsphp(as the current mainstream development language).ini or delete.

Secondly, check whether the directory where the php (as the current mainstream development language) file has sufficient permissions (I set it to Everyone - full control, which is not used for development anyway. Considering so many security restrictions).

Fastcgi(not many people are using it now) mode to run php(as the current mainstream development language) Advantages:
Use Fastcgi(Not many people are using it now) Mode running php(as the current mainstream development language) has several main benefits. The first is php(as the current mainstream development language). When an error occurs, it will not bring down apache(the most popular WEB server platform on the Unix platform), but php(does For the current mainstream development language) its own process crashes (but Fastcgi (not many people are using it now) will immediately restart a new php (as the current mainstream Development language) process to replace the crashed process). Secondly, Fastcgi(not many people are using it now) mode runs php(as the current mainstream development language) which has better performance than ISAPI mode (I originally used apache (The most popular WEB server platform on Unix platform) Bench was tested, but forgot to save the results. If you are interested, you can test it yourself).

Finally, you can run php(as the current mainstream development language)5 and php(as the current mainstream development language)4 at the same time. Referring to the configuration file below, two virtual hosts were established, one using php(as the current mainstream development language)5, and the other using php(as the current mainstream development language) )4.

LoadModule fastcgi(Not many people are using it now)_module modules/mod_fastcgi(Not many people are using it now)-2.4.2-AP13 .dll

ScriptAlias ​​/fcgi(not many people use it now)-php(as the current mainstream development language)5/ "d:/ usr/local/php(as the current mainstream development language)-5.0.4/"
Fastcgi(not many people are using it now)Server "d: /usr/local/php(as the current mainstream development language)-5.0.4/php(as the current mainstream development language)-cgi(now Not many people are using it anymore).exe" -processes 3
ScriptAlias ​​/fcgi(Not many people are using it anymore)-php(As the current mainstream development Language)4/ "d:/usr/local/php(as the current mainstream development language)-4.3.11/"
Fastcgi(not many people anymore In use)Server "d:/usr/local/php(as the current mainstream development language)-4.3.11/php(as the current mainstream development language) .exe"

Listen 80
NameVirtualHost *:80

DocumentRoot d:/www
Options Indexes FollowSymlinks MultiViews
ServerName php(as The current mainstream development language)5.localhost

AddType application/x-httpd-fastphp(as the current mainstream development language)5.php(as the current mainstream development language) The current mainstream development language)
Action application/x-httpd-fastphp(As the current mainstream development language)5 "/fcgi(Not many people are using it now )-php(as the current mainstream development language)5/php(as the current mainstream development language)-cgi(not many anymore People are using it).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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508537.htmlTechArticleI have always been running PHP (as the current mainstream development language) in ISAPI mode. This way The biggest disadvantage is its poor stability. When PHP (as the current mainstream development language...

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