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>