Microsoft Azure Open Source Development Support Team Blog

Support for Open Source Technologies on Microsoft Azure App Service

Run PHP Webjob on Azure App Service (Windows)

When you deploy a webjob to run PHP program, there are few items to verify and help to understand the PHP runtime for webjobs.

1. How to create a PHP webjob
– Execute a .php file
– Create batch to execute .php file
– Create shell to execute .php file

2. PHP runtime for webjob uses the PHP in Kudu container, which is difference from the PHP runtime for webapp, to verify the PHP runtime, you can trigger a webjob export phpinfo, or run the following command from Kudu ‘Debug console’,

   php -i > phpinfo.txt

3. From phpinfo.txt (if you run a phpinfo from webjob, check the output log),

– find the php.ini location
Loaded Configuration File => D:\Program Files (x86)\PHP\v7.1\php.ini

– find PHP_INI_SCAN_DIR
Scan this dir for additional .ini files => d:\home\site\ini
Additional .ini files parsed => d:\home\site\ini\settings.ini

You can define PHP_INI_SCAN_DIR in App Settings:

– find if PHP error log is enabled
log_errors => Off => Off

– find PHP error log file location (you can modify this location in additional .ini file defined in PHP_INI_SCAN_DIR, e.g. d:\home\site\ini\settings.ini)
error_log => D:\Windows\temp\php71_errors.log => d:\Windows\temp\php71_errors.log

– Enable PHP extensions
Check from Kudu, default installed PHP extensions are listed in D:\Program Files (x86)\PHP\v7.x\ext
If you use PHP 7.x 64-bit, check from D:\Program Files\PHP\v7.x\ext
To enable an extension in this list, add it in additional .ini file, for example,

extension=php_ldap.dll

– Install PHP extensions
If the PHP extension is not available from default extension list, download the matching version, for example, you can put it in d:\home\site\ext, then add the extension in additional .ini file, e.g.

extension=”D:\home\site\ext\php_redis.dll”

– Use “-c” option to specify php.ini in command, e.g.

php -c [Path to php.ini file] [Path to .php file]