Load Custom Configuration (.ini) in PHP for Azure App Service
Published Jul 18 2023 08:22 PM 4,449 Views

As a PHP developer, sometimes you might want to set the custom configuration file (.ini) to read when PHP starts up. For this article, I would like demonstrate how to load custom configuration file (.ini) in the Azure App Service.


By default, we set the PHP_INI_DIR = /usr/local/etc/php/conf.d, so when using SSH on Kudu, you could see there are lots of .ini files:



Based on this, you might think we could just manually add our custom .ini files in /usr/local/etc/php/conf.d, but it will not work after restart. Since only "/home" data will be persistent after restarting App Service. So what we need to do is to add our .ini in "/home", E.g. "/home/site/ini"


For example, if I would like to modify "upload_max_filesize to 64M (defualt is 2M) and post_max_size to 64M (default is 8M)" for the PHP website, I could follow the below steps to achieve it:


Step 1:

Use like vi/vim command to add setting.ini file in the "/home/site/ini" folder



Step 2:

PHP supports scanning multiple directories for .ini files. For this we need to set PHP_INI_SCAN_DIR with ":" to separate values on the Application Setting for the target App Service.

E.g. PHP_INI_SCAN_DIR = :/home/site/ini

This ensures that we load *.ini files from  /usr/local/etc/php and then load from /home/site/ini




After, we check the value by simple php page and it will show upload_max_size and post_max_size are set as 64M now.




Version history
Last update:
‎Jul 18 2023 07:54 PM
Updated by: