Changing the php.ini File for Web Workers in Windows Azure Pack Websites v2

As some of you may have noticed with Windows Azure Pack Websites v2, you can have the user to specify certain settings inside the .user.ini file if they want to enable fancy PHP options.

However, what if you want to make those changes applied globally to all of your tenant’s web sites by default? Doing some quick Google searches leads you to a dead end. However I accidentally discovered this trick when I was upgrading a lab web farm from Update 4 to Update 6.

Apparently, Windows Azure Pack Websites ships with PowerShell cmdlets. They’re useful for provisioning new web workers, load balancers and publisher servers as needed when your resource demand requires so. However, most of those cmdlets aren’t really clearly documented on how they are to be used.

In this scenario, we want to alter some of the php.ini directives globally for our websites. In this case, we use the Get-WebsitesConfig and Set-WebSitesConfig cmdlets to do our dirty work. First of all, we’ll need to get the FileId of the specific PHP version we’re going to modify.

PS C:\Users\Administrator.ADL\Documents> get-websitesconfig -Type ConfigFile

FileId DestinationPath Content
------ --------------- -------
PHP53INI %ProgramFiles(x86)%\PHP\v5.3\php.ini [PHP]...
PHP54INI %ProgramFiles(x86)%\PHP\v5.4\php.ini [PHP]...
PHP55INI %ProgramFiles(x86)%\PHP\v5.5\php.ini [PHP]...
PHP56INI %ProgramFiles(x86)%\PHP\v5.6\php.ini [PHP]...

By using that cmdlet above, we’ve gotten a list of FileId’s available to us for editing. In this example, we’re going to edit the php.ini file associated with PHP 5.3. In order to do that, we’ll need to grab the contents and dump it to a temporary file for that specific php.ini file.

(Get-WebSitesConfig -Type ConfigFile -FileId PHP53INI).Content | Out-File temp.ini

Now use your favorite text editor to change the contents of temp.ini. Once you’re done, you’ll need to sent the contents of temp.ini to the database that the controller has access to:

Set-WebSitesConfig -Type ConfigFile -FileId PHP53INI -Content (Get-Content temp.ini)

Once that’s done, you’ll need to recycle all of the affected websites for the changes to take effect.

Leave a Reply

Your email address will not be published. Required fields are marked *