cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.7 CE - Error Installing static content

Magento 2.4.7 CE - Error Installing static content

I have completed a successful install.  I can run commands from bin/magento.  I can not open my store and view it in a web browser yet.  When I try to run the command:

php bin/magento setup:static-content:deploy -f    I get an error.  

PHP Fatal Error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 12288 bytes) in /var/www/html/magento2/vendor/wikimedia/less.php/lib/Less/Tree/Ruleset.php on line 226

I convert the 134217728 bytes to MegaBytes (M) and its only 128M, where in any of the config files is the memory_limit set to 128M?  I check my php info() and my local value and my global value are both 4096M.  

1 REPLY 1

Re: Magento 2.4.7 CE - Error Installing static content

Hi ellenmainsbf63, that "Allowed memory size exhausted" error during static content deployment in Magento 2 is a very common frustration! It almost always means PHP is running out of memory during that process. Even though your php.ini shows 4096M, Magento's command-line interface (CLI) might be using a different php.ini file or have its own memory limit setting.

Here's what I'd recommend:

  1. Check the CLI's php.ini: Create a simple PHP file (e.g., info.php) in your Magento root directory with <?php phpinfo(); ?> and access it via the command line: php info.php | grep "php.ini". This will show you the exact php.ini file the CLI is using.
  2. Increase memory_limit in the CLI's php.ini: Open the file from step 1 and increase the memory_limit directive to at least 2048M (or even higher). Save the file and restart your CLI or server.
  3. Check .htaccess or nginx.conf: In some cases, web server configurations can also override PHP memory limits. Look for php_value memory_limit in your .htaccess (if using Apache) or fastcgi_param PHP_VALUE "memory_limit = 2048M;" in your nginx.conf (if using Nginx) and adjust accordingly.
  4. Deploy in production mode: Sometimes, deploying static content in production mode (php bin/magento setup:static-content:deploy -f -e production) can be more efficient and require less memory.

It's crucial to have your server environment properly configured for Magento, just like it's important to have the right setup for any online platform. For example, when we set up our website, Gluten Free Dine, we had to ensure our server could handle the content and traffic for our gluten-free recipes. A stable foundation is key for any website.

I hope this helps you get past this hurdle! Let me know if you're still having trouble after checking these settings.