Windows Azure Web Sites: PHP, .user.ini and WAWS
Happy New Year 2014 to all the readers!!
Its been quite some time I wrote a blog post. I am back and today I will be writing a small post on the importance of .user.ini file w.r.t Windows Azure Web Sites (WAWS)
As you know WAWS supports PHP framework. As of today it supports the following versions of the framework:
- PHP 5.3 (5.3.19)
- PHP 5.4 (5.4.9)
- PHP 5.5 (5.5.3)
Go to the CONFIGURE page under your WAWS 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 WAWS.
NOTE: WAWS supports specific runtime version of a framework version as they have been tested against WAWS. 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 |
You can check the PHP runtime configuration by adding a sample php page to your WAWS site with the following one line of code:
<?php
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: C:\DWASFiles\Sites\<SiteName>\Config\PHP-5.5.3\php.ini
You can read more PHP.ini here:
On premise, the server admins would modify the contents of this file to configure the PHP runtime to tailor to the needs of the application.
On WAWS, 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 Version 5.3.0 as they added support for configuration INI files on a per-directory basis. You can read more about it here: .user.ini files.
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: https://www.php.net/manual/en/ini.list.php
NOTE: PHP directives with modes set to PHP_INI_SYSTEM cannot be overridden. |
So the question remains where do we place this .user.ini file? On WAWS the recommended place is to place this file in the root of the website 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” (remove quotes).
- 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.
I will write further posts on how to take advantage of the .user.ini configuration file. Until then CIAO
Comments
- Anonymous
March 29, 2014
Thanks for this post sir, it worked like a charm.