When you create a CGI Web Role with New released Azure Cloud Tools 1.3 you will encounter a problem as below which you did not encounter with SDK 1.2 with the same steps. You will received the following error Even when your web.config and web.roleconfig are correct.:

    HTTP 500 Internal Server Error

Your web.config has the PHP Fast CGI Handler defined correctly as below:

 <?xml version="1.0" encoding="UTF-8"?>

<configuration>

  <system.webServer>

    <modules runAllManagedModulesForAllRequests="true" />

    <handlers>

        <add name="PHP Fast CGI" verb="*" path="*.php" scriptProcessor="%RoleRoot%\approot\php\php-cgi.exe" modules="FastCgiModule" resourceType="Unspecified" />

    </handlers>

    <defaultDocument>

      <files>

        <clear />

        <add value="index.php" />

      </files>

    </defaultDocument>

  </system.webServer>

</configuration>

Your also have correct full path set for PHP CGI as below in web.roleconfig:

<?xml version="1.0"?>

<configuration>

  <system.webServer>

    <fastCgi>

      <application fullPath="%RoleRoot%\approot\php\php-cgi.exe" />

    </fastCgi>

  </system.webServer>

</configuration>

 

This is a issue which you will encounter with SDK 1.3 and full IIS web role. Following are the details about why it occurred and how to solve this problem. 

After you created your CGI web role using SDK 1.3 you will see a new section name “Sites” is added in CSDEF to handle multiple sites with full IIS role as below:

<?xml version="1.0" encoding="utf-8"?>

<ServiceDefinition name="CGIPHPTest" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">

  <WebRole name="WebCgiRole" enableNativeCodeExecution="true">

    <Sites>

      <Site name="Web">

        <Bindings>

          <Binding name="Endpoint1" endpointName="Endpoint1" />

        </Bindings>

      </Site>

    </Sites>

    <Endpoints>

      <InputEndpoint name="Endpoint1" protocol="http" port="80" />

    </Endpoints>

    <Imports>

      <Import moduleName="Diagnostics" />

    </Imports>

  </WebRole>

</ServiceDefinition>

 

This new addition breaks the CGI Web Role service for not being able to process web.roleconfig which has the full path the run PHP-CGI.exe.


To solve this problem you will need to remove the “Sites”  section from the ServiceDefinition.csdef file so the final ServiceDefinition.csdef look as below:

<?xml version="1.0" encoding="utf-8"?>

<ServiceDefinition name="CGIPHPTest" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">

  <WebRole name="WebCgiRole" enableNativeCodeExecution="true">

    <!--<Sites>

      <Site name="Web">

        <Bindings>

          <Binding name="Endpoint1" endpointName="Endpoint1" />

        </Bindings>

      </Site>

    </Sites>-->

    <Endpoints>

      <InputEndpoint name="Endpoint1" protocol="http" port="80" />

    </Endpoints>

    <Imports>

      <Import moduleName="Diagnostics" />

    </Imports>

  </WebRole>

</ServiceDefinition>

 

You will receive the following warning, when you build the solution:

 

1

The web role 'WebCgiRole' is configured using a legacy syntax that specifies that it runs in Hostable Web Core. To run your web  role under full IIS, add a <Site> declaration within the service definition file. See http://go.microsoft.com/fwlink/?LinkId=19847    

ServiceDefinition.csdef

1

1

CGIPHPTest

 

 Please keep in mind that using this workaround you will use the Web Role in the legacy mode as described in the above warning.