apache+php环境搭建(windows)

本文详细介绍了PHP编译版本的选择(VC6orVC9)、PHP与Apache的集成方式对比(module vs fastcgi),以及如何正确安装和配置PHP模块(如oauth)。同时,提供了Apache的fastcgi模式环境搭建步骤及解决常见错误的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[size=large]1. 编译版本 VC6 or VC9[/size]

[b]PHP高版本只有VC9版了[/b]
从以下官方下载来看,PHP貌似5.3以后,就不再提供VC6编译的版本了。
[url]http://www.php.net/downloads.php[/url]
[url]http://windows.php.net/downloads/releases/archives/[/url]

对于这两个版本的区别,PHP官方的解释是:
[quote]If you are using PHP with Apache 1 or Apache2 from apache.org you need to use the VC6 versions of PHP

If you are using PHP with IIS you should use the VC9 versions of PHP

VC6 Versions are compiled with the legacy Visual Studio 6 compiler

VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability. The VC9 versions require you to have the Microsoft 2008 C++ Runtime (x86) or the Microsoft 2008 C++ Runtime (x64) installed

[b]Do NOT use VC9 version with apache.org binaries[/b]

VC9 versions of Apache can be fetched at Apache Lounge. We use their binaries to build the Apache SAPIs.[/quote]

根据以上说法,apache应该从apachelounge下载,而不应该使用apache.org的版本。
[url]http://www.apachelounge.com/download/additional/[/url]
不过我实际试验了下,apache.org上的2.2和PHP5.4.11一起使用,没有发现明显问题。

[size=large]2. fastcgi vs module[/size]
Apache使用php的两种模式,相比传统的module方式,貌似fastcgi速度更快。
fastcgi模式的环境搭建:
a. 下载mod_fcgid,解压缩到apache目录下即可。
b. 修改httpd.conf。在httpd.conf最后加上这么几句然后重启apache就OK了(php安装目录需修改)

LoadModule fcgid_module modules/mod_fcgid.so
FcgidInitialEnv PHPRC "c:/php"
AddHandler fcgid-script .php
FcgidWrapper "c:/php/php-cgi.exe" .php


这里我第一次操作的时候没成功,httpd的error显示:
[quote]The pipe has been ended. : mod_fcgid: get overlap result error
Premature end of script headers: index.php[/quote]
后来发现是PHP里面某个extension load失败导致的(直接点击php.exe,会有message box弹出的),解决掉该问题就好了。

module模式的环境搭建:
主要问题是PHP的VC9版本里没有php5apache2_x.dll了,这个可以到apachelounge.com下载。

[size=large]3. PHP模块的安装[/size]
想装个oauth模块,下载代码自己编译实在太麻烦。。。
最后还是去下载了编译好的binaries。。。
[url]http://downloads.php.net/pierre/[/url]
[url]http://windows.php.net/downloads/pecl/releases/oauth/1.2.3/[/url]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值