日期:2014-05-16  浏览次数:20708 次

apache+php环境搭建(windows)
1. 编译版本 VC6 or VC9

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

对于这两个版本的区别,PHP官方的解释是:
引用
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

Do NOT use VC9 version with apache.org binaries

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


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

2. fastcgi vs module
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显示:
引用
The pipe has been ended.  : mod_fcgid: get overlap result error
Premature end of script headers: index.php

后来发现是PHP里面某个extension load失败导致的(直接点击php.exe,会有message box弹出的),解决掉该问题就好了。

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

3. PHP模块的安装
想装个oauth模块,下载代码自己编译实在太麻烦。。。
最后还是去下载了编译好的binaries。。。
http://downloads.php.net/pierre/
http://windows.php.net/downloads/pecl/releases/oauth/1.2.3/