Running Nodejs and php on Same Azure website

3 minute read | By Prashanth Madi

In this Blog we would try to create a php+nodejs application using iisnode

1. Create a new azure website:

2. Integrate source control using azure portal

- Go to website default page and click on setup deployment from source control

Above step would create a Git repository and you can access its url using Deployments tab.

3. Download the chat example

For this project, we will use the chat example from the Socket.IO GitHub repository. Perform the following steps to download the example and add it to the project you previously created.

  1. Download a ZIP or GZ archived release of the Socket.IO project (version 1.3.5 was used for this document)

  2. Extract the archive and copy the examples\chat directory to a new location. For example, \node\chat.

 4. Include as dependency in package.json file or replace it with below content

  "name": "",
  "version": "0.0.0",
  "description": "A simple chat client using",
  "main": "index.js",
  "author": "Grant Timmerman",
  "private": true,
  "license": "BSD",
  "dependencies": {
  "express": "3.4.8",
  "": "^1.3.4"

 5. open index.js at root folder and change line containing  var io = require(‘../..’)(server); to below

  var io =require('')(server);

6. insert below content in web.config file at root folder of project

<?xml version="1.0" encoding="utf-8"?>
<!-- Visit for more information on WebSocket support -->
<webSocket enabled="false" />
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
<!-- check if its root url and navigate to default page -->
<rule name="Index Request" enabled="true" stopProcessing="true">
<match url="^$" />
<action type="Redirect" url="/index.php" logRewrittenUrl="true" />
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^index.js/debug[/]?" />
<!-- consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
<action type="Rewrite" url="index.js"/>

<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<remove segment="bin"/>

<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />

7. Insert sample php file in public folder to test if it works

  echo "Hello World form php";
  Chat application using nodejs - <a href="">link</a>

8. Commit your changes to Azure website using any git client using the git repository url  from deployment tab in Azure portal

Above commit process would also download all the required modules listed in package.json file into node_modules folder.

Php Application :

chat Application using nodejs :

 Troubleshooting :

1. Application crashed as / is not found

check if is installed and available in node_modules folder.