I write this article because of an odyssey of bug tracing concerning my PHP application hosted in the Windows Azure cloud.
Before the Windows Azure SDK 1.6 the configuration of PHP with Fast CGI was done in the Web.config. Here you could define the exact path of your custom PHP.
Now with the SDK 1.6 and the different folder structure defined by the scaffolder, the integration of PHP has changed. The new way is to install PHP automatically by the predefined startup scripts. So you don’t need to put the whole PHP stuff into your package. You just add your php.ini modifications and maybe your special PHP extension DLLs.
Now, when you deploy your package the startup scripts will add some environment variables, install PHP53, SQLDriverPHP53IIS and PHPManager.
That’s all quite cool, but last week my live application crashed (WORST CASE!) without any modifications by my side. I could not find the problem. A few days ago I recognized that on the compute instances runs a different PHP version than on my local dev environment. I could not figure out how this could happen. But since I know that the startup script uses webpicmdline (Web Plattform Installer for Commandline) to install the PHP stuff (s.o.) it’s clear to me. The WebPI always takes the newest PHP version for installation, and it’s not possible to set up a specific version number. In my case in need PHP 5.3.8 but WebPI installs PHP 5.3.9 which crashes my application with an ugly PHP53_via_FastCGI Error Code 0xc0000005.
Ok, how can I tell Azure to take my PHP version. The only way is to again put the whole PHP folder into the deployment package as explained in this tutorial.
I for my use case I needed to do it a little bit different:
- I put the PHP folder into MyProject\WebRole\bin\PHP\v5.3\php-cgi.exe
- The extensions are in MyProject\WebRole\bin\PHP\v5.3\ext\
- In configureIIS.cmd I changed
- To add the environment variables I leave add-environment-variables.cmd as it was
- To set user permission I leave monitor-environment.cmd as it was
These changes bring some small losings (with which I can live):
- SQLDriverPHP53IIS needs to be installed manually (ext\php_sqlsrv_53_nts_vc9.dll ).
- No IIS PHPManager (Maybe it’s possible to install it by modifing the install-php.cmd).
The startup script part in my ServiceDefinition.csdef now looks like:
<Startup> <Task commandLine="add-environment-variables.cmd" executionContext="elevated" taskType="simple" /> <Task commandLine="installCustomPHP.cmd" executionContext="elevated" taskType="simple"> <Environment> <Variable name="EMULATED"> <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" /> </Variable> </Environment> </Task> <Task commandLine="monitor-environment.cmd" executionContext="elevated" taskType="background" /> </Startup>
I renamed the configureIIS.cmd from the tutorial to installCustomPHP.cmd.
One thing: It very strange to make the experience as Azure PHP developer that there are sometime changes within the Azure Plattform which are crashing my live application. And I have no chance to get warned/informed early enough to fix the problems before my customers get a blank page.
Corrections, tips and hints are welcome