Geeks With Blogs
Confessions of an Evangelist

I’m working on a project that has a fairly complex architecture, including several web and worker roles. One of them runs on PHP and originally built on a Linux machine using Web Sphere. In the process of migrating the application to Azure we had several options for how to design the architecture, and we wanted to see how we could simplify the configuration while meeting the various requirements.  I know that PHP is supported in Azure Web Sites by simply checking  the version you want, but what about Cloud Services?

image

Figure 1.  Azure Web Sites Configuration

Back a couple years ago when I first was evangelizing Azure the only option for compute available was Platform as a Service (or PaaS). This pattern for designing cloud solutions includes the ability to simply set a number of instances and the compute fabric responds by provisioning machines and starting them up. The challenge is to make sure you codify how the configuration works because although you could use remote tools to customize a configuration, as soon as you add instances or if the fabric needs to move your running instance, the image it uses to create the new machine comes from the uploaded package you deployed. Fortunately Steve Marx (who was then working with the Azure team) created a post that does a great job of explaining how these work, so I’m not going to try to repeat it here. What I am going to do is share the plug-in I created for it which makes this type of configuration a breeze.

The creation of a plug-in for Azure Cloud Services requires an understanding of how plug-ins work, and knowing where to put the files so they can be used. When looking at how to get PHP to run on an Azure Cloud Service you need to look at how you would do it on a local machine running IIS. The way IIS works is that there are a series of modules and handlers that are executed as part of the request pipeline, and for requests that have the *.php extension you send them to the right handler. In the management console for IIS you can add a script map to handle this, assuming you have PHP installed on your local machine. The problem is that this is fairly low level and to script this as a startup would mean copying the files and then codifying the startup tasks to make the change in IIS.

image

An easier way is to use the Web Platform Installer to enable PHP. It takes care of downloading the appropriate set of dll’s and exe’s that are needed, and making the configuration change to the web server for you. The installer can be downloaded from Microsoft at http://microsoft.com/web and then it’s a simple matter of choosing the version of the PHP framework you want and clicking thru to do the install. Unfortunately for Cloud Services startup commands do provide a GUI for doing this so we need to use the command line version of the tool. If you’ve installed the 2.1 version of the Azure SDK you can find it in the plugin directory for WebDeploy (C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.1\bin\plugins\WebDeploy). The command to install a product (and accept any EULA) is this:

c:/> webpicmd /Install /AcceptEula /Products:PHP54

To codify this so that it works you’ll need to add the appropriate files to your Cloud Service and then add a startup task to run it in the ServiceDefinition file.

Posted on Monday, September 16, 2013 11:30 AM | Back to top

Copyright © Mike Benkovich | Powered by: GeeksWithBlogs.net