技术开发 频道

【第13篇】在Windows Azure中使用PHP

  第三步,下载一个"xcopy-deployable”版本的PHP。

  "xcopy-deployable”这个词来自微软的官方文档,但是很遗憾,在php的官方网站http://php.net/中,我们却没有找到这个词. - -P

  根据词义理解一下:可以直接拷贝部署的PHP版本。通俗地说就是不需要安装的。

  来到PHP官方网站的下载中心:http://www.php.net/downloads.php,在Windows Binaries部分找到最新版本号的"zip package“就可以了。比如现在php版本的最新版本是2009年3月10日的5.2.9-1,下载地址: http://cn2.php.net/get/php-5.2.9-1-Win32.zip/from/a/mirror

  第四步,新建Web Cloud Service项目。

 

  第五步,配置Service Definition 文件(ServiceDefinition.csdef)。

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="CloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  
<WebRole name="WebRole" enableNativeCodeExecution="true">
    
<InputEndpoints>
      
<InputEndpoint name="HttpIn" protocol="http" port="80" />
    
</InputEndpoints>
  
</WebRole>
</ServiceDefinition>

  注意:需要在WebRole节点下增加enableNativeCodeExecution="true"属性

  第六步:配置FastCGI和PHP

  将刚刚下载的xcopy-deployable PHP压缩包解压缩到WebRole项目的php子目录下。
 
  在WebRole项目根目录下增加Web.roleconfig文件,内容如下: 

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  
<system.webServer>
    
<fastCgi>
      
<application fullPath="%RoleRoot%\php\php-cgi.exe" />
    
</fastCgi>
  
</system.webServer>
</configuration>

  这里我们使用了"%RoleRoot%"变量来获得Web Role的根目录。这也是Match 2009 CTP版本所提供的新特性之一。
在Web.config文件的system.webServer-handlers节下增加对PHP文件的处理: 

  <system.webServer>
          
<handlers>
        
<..>
    
<add name="PHP via FastCGI"  path="*.php"  verb="*"  modules="FastCgiModule"
             scriptProcessor
="%RoleRoot%\php\php-cgi.exe"
             resourceType
="Unspecified" />
      
</handlers>
    
</system.webServer>
0
相关文章