In this post I will be discussing the usage of .user.ini in Azure App Service.

As of 16th March 2019 the following versions of PHP framework are supported on Azure App Service :

  • PHP 5.6 (5.6.39) - 32 bit
  • PHP 7.0 (7.0.33) - 32 and 64 bit
  • PHP 7.1 (7.1.25) - 32 and 64 bit
  • PHP 7.2 (7.2.12) - 32 and 64 bit

Go to the CONFIGURE page under your Azure App Service site to configure this setting. As seen in the above image the user can choose any one of the framework versions which are supported by Azure App Service.

NOTE: Support for newly released runtime versions are added once they have been tested against the Azure App Service platform. The user can also configure their own customized version of PHP framework which their application supports. This way they will have complete control over the php.ini. Please refer this URL: How to: Use a custom PHP runtime in Azure App Service

You can check the PHP runtime configuration by adding a sample php page to your Azure App Service. Add the following code snippet to it:

<?
    phpinfo();
?>

PHP picks up its configuration from the file php.ini when it starts up. If you access the above page for your site, you will see that this file resides under: D:\local\Config\PHP-<version>\php.ini

You can read more PHP.ini here:

These configuration files are modified by the admins to customize the PHP runtime.

On Azure App Service, with the default runtime versions that are provided the users cannot modify the contents of the php.ini file, so there is hardly any room for customization of PHP runtime configuration. However, the users aren’t completely helpless here. There is another configuration file, .user.ini.

Support for these files were included in PHP V5.3.0, support was included for INI files on a per-directory basis. For more info, refer this: The configuration file (php.ini)

So we can use the above file to customize/override the PHP runtime settings with the modes PHP_INI_PERDIR and PHP_INI_USER. List of php.ini directives is available here: List of php.ini directives

NOTE: In PHP the directives with modes set to PHP_INI_SYSTEM cannot be overridden.

In Azure App Service the ideal location to place the .user.ini file is the applications root folder, which is wwwroot folder.

  • connect to your website via FTP using FileZilla
  • Under Remote site: expand / and then expand the site node.
  • Click on wwwroot
  • Right click and select Create new file. enter the name of the file as .user.ini.
  • Right click the .user.ini and select View/Edit to edit the file in notepad.
  • Override the PHP settings here. Save it and then close the file.
  • You will receive a prompt notifying the file content has been changed.
  • Select the check box Finish editing and delete local file and click on Yes.
  • Start and stop the website to force the settings to be read immediately.
  • Browse the phpinfo page you created earlier to see the changes yourself.