We are trying to deploy a Laravel app to Azure.
Everything went fine until the composer started. At some point it breaks down saying that all the memory was exhausted - clearly, it looks like the PHP memory limit is ~2MB, which is obviously too little.
The problem is that we can't increase this limit in any way - we used an ini file added to the storage ( method described here and here ) and we used adding directives to .htaccess (also described here ), but none of those worked.
To make it even more strange when we navigate to the site and execute a small php file with echo <?php phpinfo();> in it it shows the PHP memory limit to be 128M - way less than what we set in the ini file, but way more than what the error reports. That would indicate that the environment composer runs in is different from the environment the site actually runs in.
What gives? Anyone had this problem?
remote: Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
remote: Fatal error: Allowed memory size of 2097152 bytes exhausted (tried to allocate 32768 bytes) in /tmp/8d8df2faa270e0a/vendor/composer/autoload_static.php on line 1724
The difference you notice is that Azure App Services run different configuration settings for CLI and web.
In order to increase memory you can modify the app service parameters in the portal where you specify PHP_INI_SCAN_DIR (as mentioned in How to add PHP.ini on Azure App Service ).
An other way is to modify your composer.json file where you modify the script with php -dmemory_limit=512M
so it will use the memory you specify in your artisan command.
If all that fails, and this is the preferred way, is to build and run all the things locally or in a CI/CD environment and create a zip file of your whole application. Use the Azure CLI to push and deploy that zip onto your App Service.
It turned out our problem had two solutions:
az webapp config appsettings
command ).
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.