日期:2011-10-08  浏览次数:20552 次

 

  CakePHP是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该项目主要目标是提供一个可以让各种层次的PHP开发人员快速地开发出健壮的Web应用,而 又不失灵活性。

  在 Windows Azure 上使用 CakePHP 的步骤:

  下载 CakePHP 2.2.1

  解压下载的压缩包

  发布到 Windows Azure 网站

  通过 FTP 上传文件到 Windows Azure 或者;

  使用 Git 发布 Windows Azure 网站应用

  构建应用

  我使用的是 CakePHP Blog Tutorial 来测试功能

  CakePHP on IIS (aka Windows Azure Web Sites)

  需要注意的是 Windows Azure 用的是 IIS 来运行 CakePHP 应用,因此需要一个 web.config 来描述应用,因为 IIS 不支持 .htaccess 文件。

  下面是在 CakePHP 网站上的一个 web.config 的示例,用于在 Windows Azure 网站上运行 CakePHP 应用:

 <?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>

<action type="Rewrite" url="index.php?url={R:1}" appendQueryString="true" />

</rule>

<rule name="Imported Rule 2" stopProcessing="true">
<match url="^$" ignoreCase="false" />
<action type="Rewrite" url="/" />
</rule>
<rule name="Imported Rule 3" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<action type="Rewrite" url="/{R:1}" />
</rule>
<rule name="Imported Rule 4" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php/{R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>