Skip to content
Advertisement

Azure Web App: how to increase PHP memory limit for the deployment process? Nothing works

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

Advertisement

Answer

It turned out our problem had two solutions:

  • app apparently ignoring the additional .ini file created inside the /home directory in Azure (as described here) -> this is solved by simply restarting the app inside Azure Portal (for Linux users this is not intuitive),
  • composer running out of memory -> this was solved by setting the environment variable COMPOSER_MEMORY_LIMIT for the app inside Azure Portal to -1 (this is accomplished by going to your app in Azure Portal, then “Configuration” and editing or adding this value in “Application settings” tab or using az webapp config appsettings command).
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement