How to Use the WebPICmdLine to Install PHP on Windows Azure
Hosted services in Windows Azure can be configured with startup tasks to install components such as the PHP runtime. These tasks are defined in the <Startup> element of the ServiceDefinition.csdef file and can be customized by their order of execution and permission level. This topic describes how to use a startup task with the command line version of the Web Platform Installer (WebPICmdLine). For more information about the <Startup> element, see the WebRole Schema topic.
Using the WebPICmdLine and a Startup Task to Install PHP on Windows Azure
-
Download the “Any CPU” version of WebPICmdLine from this location. We must use this version because all Windows Azure deployments run on 64-bit software and hardware.
-
Extract the contents of the WebPICmdLine download into a folder within your deployment.
-
Open a new Notepad document and add the following lines:
@echo off ECHO "Starting PHP Installation" >> log.txt md "%~dp0appdata" cd "%~dp0appdata" cd.. reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d "%~dp0appdata" /f "..\YourFolderName\WebPICmdLine" /Products:PHP53 /AcceptEula >>log.txt 2>>err.txt reg add "hku\.default\software\microsoft\windows\currentversion\explorer\user shell folders" /v "Local AppData" /t REG_EXPAND_SZ /d %%USERPROFILE%%\AppData\Local /f ECHO "Completed PHP Installation" >> log.txt
Modify line 11 of the script to point to the location of WebPICmdLine, then save the file as install-php.cmd in the bin folder of your deployment.
-
Open the ServiceDefinition.csdef file and add the following lines just before the closing </WebRole> element, then save the file:
<Startup> <Task commandLine="install-php.cmd" executionContext="elevated" taskType="background" /> </Startup>
When these steps are completed, the WebPICmdLine will automatically download PHP 5.3 and install it on your web role.