Condividi tramite


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.

Comments

  • Anonymous
    October 02, 2010
    Hi, Is it possible to host an asp.net page within this type of web role as well? cheers G

  • Anonymous
    December 19, 2010
    Yes, In my case. I host asp.net mvc2 and php in one webCgiRole.

  • Anonymous
    January 05, 2011
    The sample site listed at the top of this page appears to be broken?

  • Anonymous
    January 23, 2011
    Thanks for such a great post, and also its explaining about PHP is so nice. I have shared this article through Facebook and Twitter. I will be been keep on visiting your blog, so kindly update the blogs in the same manner. <a href=www.dckap.com/php-web-application-development.htm">PHP Developer</a>

  • Anonymous
    January 23, 2011
    Its so informative and interesting one which i came across recently. Sp my sincere thanks to the author for posting such a great post. The way he expalined about PHP is awesome. www.dckap.com/php-web-application-development.htm

  • Anonymous
    September 13, 2011
    Hi,   Many Thanks for this excellent blog. Unfortunately in the latest August Azure Toolkit the CGI_Web Role has been removed. It is not clear how to follow the steps in this tutorial without that template. May you please be so kind and add a few lines to this blog how this is meant to be done? Many Thanks,

  • Anonymous
    October 12, 2011
    Is it possible to host an asp.net page within this type of web role as well?

  • Anonymous
    November 14, 2011
    Demo wordpress-win-azure.cloudapp.net/ does not work...

  • Anonymous
    November 15, 2013
    The comment has been removed

  • Anonymous
    June 27, 2015
    Nice Post <a href="http://www.freeurdu-tutorials.blogspot.com">Urdu tutorials </a>