在Server Core上安装FastCGI

Published on January 30, 2008 by iisteam
Updated on February 26, 2008 by iisteam

 

介绍


FastCGI 是一种独立语言,它是CGI的灵活、开放的扩展,并且性能很高。FastCGI扩展可以安装到Server Core中,并且允许在IIS上的,诸如PHP这种应用程序架构去实现改善性能和稳定性。强烈推荐安装FastCGI去管理一个PHP应用程序。在这个例子中,我们将安装FastCGI,并且准备使用安装后的服务器管理我们的PHP应用程序。
要安装FastCGI和Static Content Web Server,将下面的文本输入到Server Core系统的命令行中

 

Start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-CGI;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;WAS-WindowsActivationService;WAS-ProcessModel

在命令行中,输入下面的AppCmd.exe命令,来创建PHP/FastCGI的句柄地图:

AppCmd set config /section:system.webServer/fastCGI /+[fullPath='d:\php\php-cgi.exe']
AppCmd set config /section:system.webServer/handlers /+[name='PHP-FastCGI',path='*.php',verb='*',modules='FastCgiModule',scriptProcessor='d:\php\php-cgi.exe',resourceType='Either']

注意:

  • - AppCmd.exe是在IIS 7.0 中包含的一个新的命令行工具。AppCmd.exe可以在%WinDir%\System32\InetSrv目录中找到。
  • - 由于依赖于PHP安装的位置,其在硬盘上的安装路径的可能需要更新。下面所有的AppCmd示例命令,均假设PHP安装在D:\PHP文件夹下。

 

在IIS 7.0上安装PHP

1. 从下面的链接下载最新的PHP版本:
http://www.php.net/downloads.php
2. 在标题为"Windows Binaries"的步骤中,选择一个扩展名为zip的存档
注意:Server Core缺少GUI界面,并且没有Web浏览器
3. 将存档的内容解压缩到Server Core系统可访问的位置,比如一个网络共享文件。
4. 创建一个拷贝解压缩文件的目录,例如:
%SystemDrive%\PHP
5. 、将之前解压缩后的PHP存档文件内容拷贝到
%SystemDrive%\PHP
6. 执行下面的命令:

rename %SystemDrive%\PHP\PHP.INI-Recommended %SystemDrive%\PHP\PHP.INI

测试PHP配置

1. 从命令行中,执行notepad.exe。在空文件中,输入或者黏贴下面的文本:

<?
phpinfo();
?>

2. 将文件名保存为phpinfo.php,并且存放在下面的位置:
C:\inetpub\wwwroot\
3. 在一个已连接的计算机中,打开浏览器窗口,浏览: http://%systemhost%/phpinfo.php
4. 一个页面将显示出来,展示PHP的配置