Host Wordpress on Windows Azure: Run PHP applications in Windows Azure

 our wordpress live sample website:

https://wordpress-win-azure.cloudapp.net/

Download sample project here

 

This tutorial article will show you how easy to run PHP applications in Windows Azure. In this tutorial, you will experience the basic process of hosting PHP applications in the cloud with Windows Azure.

Prerequisites

 

1. Firstly, download the latest version of PHP from https://windows.php.net/download/

VC9 x86 Non Thread Safe (2010-Jul-21 20:38:25) version is your best choice. At right sidebar of the download page, we can see that: VC6 Versions are compiled with the legacy Visual Studio 6 compiler.VC9 Versions are compiled with the Visual Studio 2008 compiler and have improvements in performance and stability.

As for difference between PHP thread safe and non thread safe binaries, please refer here.

 

2. Open Microsoft Visual Studio elevated as Administrator. From the File menu, choose New and then Project. In the New Project dialog, expand the language of Visual C# .In the Project types list and select Windows Azure Cloud Service. Set the name of the project to "CloudService1".Click OK.

 

Add CGI_Web Role, rename to PHP_WebCgiRole, Click OK。

 

3. Create new folder "php" in PHP_WebCgiRole project and extract the downloaded PHP in step1 to the folder "php".

 

4. Create a new file named "index.php" in PHP_WebCgiRole project.

 

.Open index.php, add the code below to it:

<?php            

phpinfo();

?>

5. Open Web.roleConfig in PHP_WebCgiRole project.

In the application element, change the fullPath attribute to "%RoleRoot%\approot\php\php-cgi.exe" and set the arguments attribute to an empty string.

 

 

 

6.Open Web.config in PHP_WebCgiRole project,locate the system.webServer section and insert the following (highlighted) configuration:

 <system.webServer>

  ...

  <modules>

    ...

  </modules>

  <handlers>

    ...

  </handlers>

    

  <defaultDocument enabled="true">

    <files>

      <add value="index.php" />

    </files>

  </defaultDocument>

</system.webServer>
 

7. Uncomment the handler named FastCGI Handler.

Change the path attribute of the FastCGI Handler to the string "*.php" to indicate that this handler should process any request for documents with this extension. Next, change the script`Processor attribute to the value "%RoleRoot%\approot\php\php-cgi.exe".

 

Verification

8. Press F5 to debug the application. You may get the error information below. Because Windows Azure will simulate the environment locally, so it requires local IIS to run PHP.

 

Open My Computer, click Uninstall or change a program, choose Turn Windows feature on or off, in the Internet Information Services,check and enable CGI option:

 

Now press F5 again, wait for the browser to start, and we'll see:

 

We can see that the PHP version is 5.3.2.

9.Press Shift+F5. Right click CloudService1 project, Click Publish and choose Create Service Package Only.(you can also choose Deploy your Cloud Service to Windows Azure instead ,refer to here)

 

After several seconds, we will get 2 files for deployment. Visit Windows Azure portal to deploy the application, then we can visit the application via URL:

 

Now we run PHP applications in Windows Azure successfully.  

 

References:

Windows Azure Platform Training Kit


In This Section<o:p></o:p>

Topic

Description

Chapter 1: Using PHP application in Windows Azure

This article will show how easy to run PHP application inWindows Azure

Chapter 2: Consume SQL Azure Using PHP

This article describes how to access SQL Azure using PHP.

Chapter 3: Host Wordpress on Windows Azure

This article describes the process about host Wordpress on Windows Azure. Similarly, you will see how easy it will be.

Chapter 4: Using Windows Azure Storage in Wordpress

This article introduces the Windows Azure Storage plugin for WordPress . It enables Wordpress store multimedia contenton Windows Azure Storage.