How To Do PHP Deployment To Windows Azure

April 18 2011

You have a PHP application that targets PHP 5.3. You want to deploy it to Windows Azure. You do not have Visual Studio.  How do you do it?

Step 1 – Download The Windows Azure SDK (9 MB).

Step 2 – Download this .zip folder which will serve as the shell directory structure for your files. Unzip it.  It looks like this:

/root
  /AppFolder
    /bin
    /assets
    /putmoduleshere

Step 3 – Copy/Paste your web directory into the /AppFolder directory.  This would include all your .php, .html, .jpg and all other assets for the website. Do not delete any of the sub directories that exist in the AppFolder directory, such as the /bin folder or the /assets folder.  Also, do not delete the web.config that is in the /AppFolder directory.

Step 4 – Run the PackageCloud.cmd from the /root directory. This will create a file called ServiceDefinition.cspkg in the /root. 

Step 5 – Log in to http://windows.azure.com. Create a New Hosted Service.  When asked to chose a package, browse to the ServiceDefinition.cspkg that you created in Step 4.  When asked to upload a Configuration file,  ServiceConfig.cscfg which can also be found in the /root directory.

That’s it!  Note that the ServiceConfig.cscfg creates two instances of your site.  You can change your instances by changing the number established in that file, which is an xml file.

You can see the what default modules are supported by PHP on Azure looking at this page, which is a website I deployed to Azure using this very package. If you have php modules that you need deployed that aren’t here, you’ll need to add them to the /putmoduleshere directory and redeploy.  Note: I haven’t tested this, so I can’t guarantee it will work. If you do use this methodology to add PHP modules to Azure, leave a comment on this blog and report back your findings.

If you need to update any of the files for you website, you will need to copy those new files into the AppFolder directory and repeat steps 3 – 5.

Thanks to David Aiken and SyntaxC4’s post for helping to figure this out.  Both of these guys are Azure rockstars.

Comments (3) -

5/5/2011 1:11:20 PM #

Karsten Januszewski

Be sure to also check out www.interoperabilitybridges.com/.../windows-azure-command-line-tools-for-php which is another solution to this problem and "more supported" than the work I did.

Karsten Januszewski

5/21/2011 6:27:19 AM #

Azee

Do you know if it's possible to incorporate a PHP app with a MVC app in Azure? Thanks.

Azee

5/23/2011 7:35:36 AM #

rhizohm

I don't see why you couldn't do that.  Would be an interesting question to throw out to the guys who run the PHPAzure Codeplex project.

rhizohm

Pingbacks and trackbacks (2)+

Add comment

biuquote
  • Comment
  • Preview
Loading