This post will get you started with PHP development in Visual Studio for deployment to Windows Azure.
Using the FastCGI capabilities of IIS you can run PHP application on IIS and Windows Azure (in your local Development Fabric on in the Windows Azure cloud).
So, here’s how to create a simple PHP application in Visual Studio 2010 on Windows 7.
If you want to see this in video, check out my screencast interview with Dot Net Rocks TV on Azure and go to point 48:40.
- Download the latest Windows ZIP files from http://windows.php.net/download/ (currently 5.3.2). You should get for the VC9 x86 Non Thread Safe version. The FastCGI system on IIS makes the use thread-safe. Unzip the files into a folder somewhere on your system and rename the folder "PHP".
- Ensure you have everything for IIS and CGI (i.e. FastCGI) is activated on your system for local development.
- Install the latest Azure SDK (checking the system requirements) – currently 1.1 (Feb 2010).
- Start Visual Studio 2010 (which must be in run as an Administrator for the current version of the SDK) and create a new VS Cloud Project…
- Add the CGI Web Role…
- Open an Explorer window and locate your downloaded and extracted PHP folder. Do a Copy on the PHP folder.
- Open the folder for the web project…
- Paste the PHP folder (and therefore subfolders) into the web project folder and then select the Show All Files option in Solution Explorer so you can see the pasted PHP folder…
- Use the "Include in Project" option on the php folder to include it in project files, and therefore in the files deployed to Azure.
- Edit the Web.roleconfig file, (putting a new <application/> tag in place like this which tells IIS (locally or in the cloud) about the FastCGI interpreter for PHP…
- Edit Handers section of the Web.config file to include this new <add/> tag which tells IIS to use the PHP interpreter for files ending with .PHP…
- Also add the new <defaultDocument/> tag above to set up "index.php" as the default document for the web application.
- Finally add a basic index.php file using Add New Item on the web project; since there is no .PHP item – use a .TXT item (in the General category) and give the new file a .PHP extension…
- Enter this basic PHP code:
<? phpinfo(); ?>
Start up the application and you should see something like the following:
You can now deploy this (or a real application) to Azure using the Publish function on the Cloud project as usual.
Check out this MSDN page for general help on using FastCGI interpreters with Azure.
Microsoft and Open Source Communities are sponsoring the Make Web Not War conference on May 27th 2010, showcasing the latest cross-platform techniques and technologies, including presentations, panels, workshops, a codefest, the FTW coding competition and a party! Open Data, HTML 5, PHP, JQuery, Mobile, SEO and the Cloud, are amongst the topics being covered. Speakers and panelists will include myself, Microsoft Canada team members and many open source experts.
4 thoughts on “Getting Started with PHP on Windows Azure”
[…] Check out his blog post here https://colinizer.com/2010/05/05/getting-started-with-php-on-windows-azure/?utm_source=twitterfeed&am… […]
[…] adds to Colin's great blog post and […]
[…] Cloud. If you would like to learn more about Windows Azure, check out Colin’s Post on Deploying a PHP Application on Azure. I also have a number of posts on converting, and deploying applications on Windows […]
[…] CGI Web Role – a web role that runs in IIS under the Fast CGI module. Fast CGI enables the execution of native code interpreters, like PHP, to execute within IIS. If you’re looking for more information on this topic, check out Colinizer’s blog post. […]
Comments are closed.