Highly Scalable PHP-Step 01 – Introduction

At a glance – what you will learn:

  1. Why PHP in the cloud?
  2. Installing PHP under Windows
  3. Running Expression Web to test PHP

PHP in the cloud

This blog entry is about running PHP in the cloud. Why would you want to run PHP in the cloud?

We will work with our Azure data storage constructs (Blogs, Queues, Tables).


Here is why?

  • On-Demand Computational Resources
  • Storage at Massive Scale
  • Automated Service Management
  • Goal: Give You More Time to Write Code

More Reasons that Cloud Computing is relevant

  • Add Web service capabilities to existing packaged applications.
  • Build, modify, and distribute applications to the Web with minimal on-premises resources.
  • Perform services (large-volume storage, batch processing, intense or large-volume computations, etc.) off premises.
  • Create, test, debug, and distribute Web services quickly and inexpensively.
  • Reduce costs of building and extending on-premises resources.
  • Reduce the effort and costs of IT management.

Skills of your Choice

  • Languages
  • Tools
  • Application Components


High Level Steps

The setup to do all this is very easy. Just follow the steps in this blog and you will get PHP up and running very easily. IIS is one of the first things we’ll configure. IIS is the web server.

There are two main steps:

  • Enable FastCGI support in IIS 7.0
  • Install and configure PHP

There are some configuration files we'll need to modify

When Visual Studio is used to create a PHP project, there will be a couple of configuration options we'll need to set. In order to run PHP in the cloud, we'll need to deploy the PHP runtime up into the cloud. Luckily, that is automatic and is part of the whole configuration process.

Run locally – Deploy to cloud

The good news is that we can run our project locally before uploading it into the cloud. This is an important feature because you always want to debug your application locally on your computer before uploading it up to the cloud.

PHP can run locally in the Azure development fabric, which acts as an abstraction layer to simulate how your application will ultimately run in the cloud.

What is FastCGI?

FastCGI provides a high-performance alternative to the Common Gateway Interface (CGI), a standard way of interfacing external applications with Web servers that has been supported as part of the IIS feature-set since the very first release.

FastCGI comes into play every time the web server receives a request and will generate a response back to the client browser.

CGI is a protocol for interfacing external applications to web servers. CGI applications run in a separate process, which is created at the start of each request and torn down at the end. This "one new process per request" model makes CGI programs very simple to implement, but limits efficiency and scalability. The operating system process creation and destruction overhead becomes significant and limits scalability.


FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once.

IIS (the Apache substitute) is able to overcome the multithreading challenges be re-using CGI processes to service subsequent requests.

FastCGI won't take down a web server

In order to run PHP on your local computer, you will need to install FastCGI.

FastCGI runs applications in processes isolated from the core Web server, which provides greater security than APIs, thereby minimizing or eliminating a crashed web server.

Installing FastCGI

By far the easiest way is using the web platform installer. I am running Windows 7 with IIS 7.


Navigate to the web platform installer:




Install PHP as seen below.


It will take only a few minutes.



PHP Is Now Installed – Next step is to test it

You can even see that PHP was installed in the “C:\program files” folder. An important file here is the configuration file, php.ini.

This file controls many aspects of PHP's behavior.  In order for PHP to read it, it must be named 'php.ini'.  PHP looks for it in the current working .


There are some key settings that get setup automatically. You do not need to change them.


Figure:   PHP.ini file contents

All these settings have been automatically added, even to “applicationHost.config.”

Also add the PHP_FCGI_MAX_REQUESTS environment variable and set its value to 10000, which is equal to instanceMaxRequests set in the above command.




Time to test our PHP setup

Since I’m an evangelist and since this may provide some value, I will briefly talk about using Expression Web to create and maintain web sites.

Expression Web 3

Microsoft Expression Web will be used to test our PHP abilities. You can test your PHP configuration in other ways as well.

Detailed Steps:


Creating a New PHP Site with Expression Web

From Expression Web, select “New Site"


Using a cool template


Telling Expression Web to do PHP

You will need to configure Expression Web so that it can render your php code.


If the Web Platform Installer succeeded, then you will be able to enter the path below.


Renaming our html file to be PHP

Right mouse click to rename.


After renaming to default.php

The dialog box below is Expression Web being really nice, offering to fix all the references to your newly renamed files.


Add some PHP Code

Start by opening “default.php.”

We will change “Heading 2” to “<?php print “php on windows is easy!”; ?>


We are ready to run after making the change below.


Run “default.php” in the browser to work


The final outcome is php running under Windows with little or no fuss. 


Next Steps – PHP running under Azure

[more to come…]

Comments (0)

Skip to main content