Retaining PHP settings on Windows Azure from your local development environment

March 2, 2011

Newer Note: The Interoperability Team at Microsoft has annouced a new version of the Windows Azure SDK for PHP which contains a set of shiny new command line tools and has deprecated the Windows Azure PHP Command-line Tools project. See http://azurephp.interoperabilitybridges.com for documentation on the new SDK tools

 

I ran into an interesting little issue today with the Windows Azure Command-Line Tools. It took some time to debug but I eventually figured it out. When you run package.php there is a parameter –phpRuntime that you set to let package.php know where your PHP environment is. Package.php then makes a copy of this folder and places it inside the res folder, which is inside the tool folder. This is fine in many cases however when I tried to use the OpenSSL extension I was unable to do so. A quick check on the cloud showed that Windows Azure did not have OpenSSL installed. I knew this had to be incorrect as it used my PHP environment which does have OpenSSL. After a long and mysterious journey I found that the php.ini file which was uploaded to Windows Azure was the correct file, however I had to update it in order to make my extensions work. After I ran package.php with –phpRuntime, I manually edited the php.ini file in the res folder to set the location for my extensions and reran package.php without the –phpRuntime parameter. Viola! Fixed! If you are having similar issues look into the steps I followed below.

The reason this all started was because of an error I received:
Unable to find the socket transport “ssl” – did you forget to enable it when you configured PHP?

The fix required the following steps.

  • Open Explorer and navigate to the directory in which you installed the Windows Azure Command-Line Tools
  • Open the res folder
  • Open the php folder
  • Open the runtime folder
  • Inside you will find the php.ini file. Open it for editing
  • Look for the line starting with ‘extension_dir’
  • Set extension_dir to “.\ext”
  • Save the file and try your build again and you should see your missing extension!