Today, I installed a php environment on a new server, but when running it prompted a Fatal Error: Allowed memory size of xxxxxx bytes exhausted, which means there is insufficient memory. Let me introduce several ways to solve these problems.
Solution
Method 1: Edit php.ini In php.ini
Find the "memory_limit" item. If not, you can add this parameter yourself at the end of the file. Here are some setup examples
memory_limit = 128M; You can change 128M to any value you want to set
Method 2: .htaccess
Note: This method only takes effect when php is executed with the Apache module. Find the ".htaccess" file in the root directory of your website. If you don't have one, you can create one yourself. Then put the following configuration into it
php_value memory_limit 128M; You can change 128M to any value you want to set
Method 3: Modify PHP’s memory settings at runtime
Just add the following command line to your php code.
ini_set('memory_limit','128M');
Friendly reminder
If you are using php5.2.17, the above methods may not work for you. This official bug cannot solve some problems. We can only reinstall the php environment, such as php5.4