最近按照这个配置搭建了一个环境,现在把搭建的步骤分享一下。欢迎大家拍砖。1、安装包
PHP 5.3 (5.3.2):
http://windows.php.net/downloads/releases/php-5.3.2-nts-Win32-VC9-x86.zip
Microsoft Visual C++ 2008 Redistributable Package (x86):http://219.239.26.10/download/4964789/6004174/2/exe/168/61/1273409831080_829/vcredist_x86.exe
Microsoft FastCGI Extension for IIS 5.1 and 6.0:
http://download.microsoft.com/download/E/0/C/E0C0709A-66E5-4113-9A6C-A5F65BF6717D/fcgisetup_1.5_rtw_x86.msi
SQL Server Driver for PHP:
http://download.microsoft.com/download/9/D/9/9D9F2027-44C4-4D15-9FF7-F0C627370F81/SQLServerDriverForPHP11.EXE
SQL Server 2008 Native Client ODBC driver for x86:
http://download.microsoft.com/download/0/E/6/0E67502A-22B4-4C47-92D3-0D223F117190/sqlncli.msi2、安装上面的程序
其中,php解压缩到c:\php,SQL Server Driver for PHP解压后的文件php_sqlsrv_53_nts_vc9.dll放到c:\php\ext3、c:\php和c:\php\ext加入到环境变量path中4、配置FastCGI,执行下面的命令
cscript %windir%\system32\inetsrv\fcgiconfig.js -add -section:"PHP" -extension:php -path:"C:\PHP\php-cgi.exe"
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -InstanceMaxRequests:10000
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHP_FCGI_MAX_REQUESTS:10000
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -ActivityTimeout:90
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -RequestTimeout:90
cscript %windir%\system32\inetsrv\fcgiconfig.js -set -section:"PHP" -EnvironmentVars:PHPRC:"C:\php\"
注意,最后这个是php.ini配置文件的路径,你的php.ini放到哪里,这个目录就配置到哪里。我把php.ini放到了c:\php下面了。5、配置php.ini
将php.ini-development拷一份,放到c:\php下面。
php.ini中配置下面的东西
fastcgi.impersonate = 1
fastcgi.logging = 0
cgi.fix_pathinfo=1
cgi.force_redirect = 0
extension_dir = "C:\php\ext\"
log_errors = On
error_log = "D:\testapp\php-error.log"(这个是错误日志地址和文件。)
extension=php_sqlsrv_53_nts_vc9.dll(这个是SQLServer的dll)6、配置IIS
新建网站就不说了。
Internet 信息服务(IIS)管理器-你的网站-属性-目录安全性-身份验证和访问控制-编辑,勾选启用匿名访问
你的网站的目录(我这里是D:\testapp)-右键-属性-安全-添加,增加IIS匿名账户的权限。
Internet 信息服务(IIS)管理器-你的网站-属性-文档,增加index.php至此配置完成。说明一下:
SQLServer2005以后,微软提供了php驱动,就是SQL Server Driver for PHP,不需要使用PHP自带的dll
WINDOWS环境下IIS采用VC9无线程保护的PHP,Apache采用VC6的PHP。这个是官方手册里面说的。
通过SQL Server Driver for PHP连接SQLServer还需要SQL Server 2008 Native Client ODBC driver。这个2005 2008都能用。最后,写个index.php
<?php
phpinfo()
?>
看看页面上有什么?
Registered PHP Streams这一段应该有sqlsrv这个东西了。