简体   繁体   中英

How to run a PHP file in an Azure WebJob from a bat file with your .user.ini and custom extensions?

If you try to use third party software (eg, Piwik) using the WebJobs feature provided by Azure, you might run into the issue that PHP neither loads the custom .user.ini nor the user extensions you enabled in the Azure portal.

Since you might also use third party software, you are also required to use the PHP from the CLI (.bat file) and can't upload a custom PHP file to be executed in the correct environment.

I resolved this by redefining the PHP_INI_SCAN_DIR and specifying the extensions as arguments for php.exe.

set PHP_INI_SCAN_DIR=D:\home\site\wwwroot\
php.exe -dextension=D:\home\site\path_to_your_extension.dll -f "D:\home\site\wwwroot\your_php_file.php"

For Piwik, it might look like the following:

set PHP_INI_SCAN_DIR=D:\home\site\wwwroot\
php.exe -dextension=D:\home\site\bin\php71\php_igbinary.dll -dextension=D:\home\site\bin\php71\php_redis.dll -dextension=D:\home\site\bin\php71\php_geoip.dll -f "D:\home\site\wwwroot\console" core:archive --url=https://your.url.com/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM