If you're working with a PHP website, Magento in my case, and you get a page that is half blank when loading it's possible that you're experiencing a fatal PHP error. This quick post will show you how to fix this in Magento 1.6.1.0.
Overview
Step 1: Verify the error
To verify that you are experiencing a fatal PHP error related to the memory size available you must first find your PHP error log file. My host provides this through cPanel but if you're using your own Apache server it can usually be found in /var/logs/apache2/errors.log (see below).
Open using whatever editor you like (geany in my case), when opened, I was seeing this:
My log was giving this error:
If you get something similar, the PHP script is trying to use more memory than is allocated by the current PHP configuration. There's two steps to fix this in Magento.
Step 2: Update the .htaccess file
Open the .htaccess file is located in your magento webroot in my case public_html. Find the php_value memory_limit line and set it to a higher value. I changed mine from 64M to 256M, ideally you want to keep this as low as possible. So anything like 96M, 128M, etc.. will work.
Also make sure your max_execution_time is large enough as working with large executions may cause an error if exceeded. I left mine at 18000 (see below).
Step 3: Update the php.ini file
Lastly we have to set the same memory limit in the PHP configuration (depending on your server setup). If you're webroot has a php.ini.sample, file you can simply rename it to php.ini and then edit the memory_limit and max_execution_time as follows:
; This file is for CGI/FastCGI installations.
; Try copying it to php5.ini, if it doesn't work
; adjust memory limit
memory_limit = 256M
max_execution_time = 18000
When finished the php.ini file should look similar to the picture below, save it to your webroot.
Now save and reload the page that was failing to load before. Good luck!
Overview
- Verify that you're getting a fatal PHP error related to memory size
- Update your .htaccess file
- Update your php.ini configuration
Step 1: Verify the error
To verify that you are experiencing a fatal PHP error related to the memory size available you must first find your PHP error log file. My host provides this through cPanel but if you're using your own Apache server it can usually be found in /var/logs/apache2/errors.log (see below).
Open using whatever editor you like (geany in my case), when opened, I was seeing this:
![]() |
Apache2 error.log file showing a PHP Fatal error |
My log was giving this error:
[23-Nov-2011 17:13:12] PHP Fatal error: Allowed memory size of 67108864
bytes exhausted (tried to allocate 169556 bytes) in
/path/to/magento/app/code/core/Mage/Core/Block/Abstract.php
on line 888
If you get something similar, the PHP script is trying to use more memory than is allocated by the current PHP configuration. There's two steps to fix this in Magento.
Step 2: Update the .htaccess file
Open the .htaccess file is located in your magento webroot in my case public_html. Find the php_value memory_limit line and set it to a higher value. I changed mine from 64M to 256M, ideally you want to keep this as low as possible. So anything like 96M, 128M, etc.. will work.
## adjust memory limit
# php_value memory_limit 64M
php_value memory_limit 256M
php_value max_execution_time 18000
# php_value memory_limit 64M
php_value memory_limit 256M
php_value max_execution_time 18000
Also make sure your max_execution_time is large enough as working with large executions may cause an error if exceeded. I left mine at 18000 (see below).
![]() |
Set the php memory_limit in the Magento .htaccess file |
Step 3: Update the php.ini file
Lastly we have to set the same memory limit in the PHP configuration (depending on your server setup). If you're webroot has a php.ini.sample, file you can simply rename it to php.ini and then edit the memory_limit and max_execution_time as follows:
; Try copying it to php5.ini, if it doesn't work
; adjust memory limit
memory_limit = 256M
max_execution_time = 18000
When finished the php.ini file should look similar to the picture below, save it to your webroot.
![]() |
Set the memory limit in the php.ini |
Now save and reload the page that was failing to load before. Good luck!
Thanks for the post
ReplyDeletevery useful for me.
hi, May I know what kind of Hosting you are using?
ReplyDeleteI have a problem with Site5's shared host (store with 14k products) and they suggest me to change to VPS.
Although I did all the thing above (and tried many other different on magento forum), it didn't work out.
So May I know your shared host so I can change to?
Thank you.
Hieu
thank u so much!!!!
ReplyDeleteNice Way. Thank you so much :)
ReplyDeletethanks for posting, very helpfull, but i still having this error when i uploading easted of the fact that i increase the max_post data size and the max size of the upload file en php.ini. something it works something i have the error, do you have an idea for me, thanks.
ReplyDeleteA debt of gratitude is in order for the post
ReplyDeleteextremely valuable for me.
Article Submission sites| Latest Updates| MBA Talks