"Azure Services Platform Step by step-13th" using PHP in Windows Azure

Source: Internet
Author: User
Keywords HTTP this Microsoft name
Tags .net beginning cloud configure download echo file http
At the Microsoft MIX09 Conference, Windows Azure released its 3rd version of--match 2009 CTP. Starting with this release, Windows Azure is beginning to support fastcgi. (See Mix09-windows Azure (procures 2009 CTP) in the exciting new features at a glance, by the stream cattle Trojan) support fastcgi, which means that the support of PHP, Ruby, Python and other current popular "non-Microsoft" Web applications. We are delighted to see Azure Services platform Take the first step towards an "open platform".

PHP may be the most popular language in the current web development world, so the question of "using PHP in Azure" has aroused a lot of people's attention, and Niuma himself has received several anxious help from friends in the last two days.

It may be that the bulls of Microsoft have been busy MIX09 recently, mentioning that Azure supports "FastCGI" with a lot of news coverage, but barely mentions how to configure PHP in Azure. Even in the new Azure SDK, the FASTCGI sample is not used in PHP.

Don't worry, in this article, the Stream Cow Trojan will demonstrate the most detailed process of using PHP in Azure.

(demo:http://ibm.cloudapp.net/php.php deployed to the cloud)

The first step, you must know some basic knowledge about php&fastcgi.

FastCGI's official website: http://www.fastcgi.com/

PHP fastcgi mode: http://www.blogme.cn/node/6529

The second step is to enable the FastCGI module in your IIS7.

"Note: Local debugging environment required. If you plan to deploy directly to the cloud, you do not need this step. 】

(for example, the following Vista Ultimate Chinese version:)

Open Control Panel and go to "turn on or off Windows features"

 

Enable the following modules (part of the red box in the figure)

 

Download and install the latest fastcgi module: http://support.microsoft.com/kb/967131

The third step is to download a "xcopy-deployable" version of PHP.

The word "xcopy-deployable" comes from Microsoft's Official document, but unfortunately we don't find it in the http://php.net/of PHP's official website. -P

To understand the meaning of the word: You can directly copy the deployed PHP version. In layman's parlance, there is no need to install.

Come to the Download center of the official PHP website: http://www.php.net/downloads.php, in the Windows binaries section find the latest version number of "Zip package" on it. For example, now the latest version of PHP version is March 10, 2009 5.2.9-1, download Address: Http://cn2.php.net/get/php-5.2.9-1-Win32.zip/from/a/mirror

Step fourth, create a new web Cloud service project.

The picture is not clear? Please click here to view the original image (larger).

Step Fifth, configure the service Definition file (servicedefinition.csdef).

<?xml version= "1.0" encoding= "Utf-8"?>
<servicedefinition name= "CloudService1" xmlns= "Http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" >
<webrole name= "Webrole" enablenativecodeexecution= "true" >
<InputEndpoints>
<inputendpoint name= "Httpin" protocol= "http" port= "no"/>
</InputEndpoints>
</WebRole>
</ServiceDefinition>

Note: You need to increase the enablenativecodeexecution= "true" attribute under the Webrole node

Step Sixth: Configure FastCGI and PHP

Unzip the xcopy-deployable PHP compression package that you just downloaded to the PHP subdirectory of the Webrole project.

 

Add the Web.roleconfig file under the root directory of the Webrole project as follows:

<?xml version= "1.0" encoding= "Utf-8"?>
<configuration>
<system.webServer>
<fastCgi>
<application fullpath= "%roleroot%phpphp-cgi.exe"/>
</fastCgi>
</system.webServer>
</configuration>

Here we use the "%roleroot%" variable to get the root directory of Web role. This is also one of the new features offered by the match 2009 CTP version.

Add processing to the PHP file under the System.webserver-handlers section of the Web.config file:

<system.webServer>
<handlers>
. >
<add name= "PHP via FastCGI" path= "*.php" verb= "*" modules= "Fastcgimodule"
Scriptprocessor= "%roleroot%phpphp-cgi.exe"
Resourcetype= "Unspecified"/>
</handlers>
    
</system.webServer>

Seventh Step: Write some simple code test it!

Code:

<?php
$iipp =$_server["REMOTE_ADDR"];
echo "Your IP address is". $iipp. <br/> ";
echo "This is the text that is output with the PHP echo command. <br/> ";
echo "<h1><font color= ' Red ' ><b>hello PHP on azure!</b></font></h1><br/>";
echo "<a href= ' http://azure.cnblogs.com/' >" Azure blog </a><br/> ";
echo "<font color= ' Blue ' > Below is the system variable for the current PHP environment: </font><br/>";
Phpinfo ();
?>
Effect Chart:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.