You may have visited one of your WordPress websites, or another script on your server and received this error upon landing on one of the pages:

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 524288 bytes) in /home/username/public_html/wordpress/something/filename.php on line 1593

This error is caused by your php script needing access to more memory. By default, a server comes with a certain amount of memory set in the php.ini that your scripts are allowed to access. Sometimes this number can be as low as 32MB. Some WordPress themes or plugins need a bit more than that though.

To resolve this issue on a cPanel server, there are two methods to do this. Both are very easy to do, one of them is from shell and the other is from right within WHM.

Method #1: From Within WHM as root

1) First login to WHM as the root user

2) Click on Service Configuration

3) Click on PHP Configuration Editor

You should then be at:

Home »Service Configuration »PHP Configuration Editor

On this page, you will find an option (under the “directive” row) labeled:

memory_limit

Change the value of this option from the current number its at to a higher one. I recommend going up by 32MB. So if you had 32M listed there, you would change it to:

64M

Then click “save”. When this is done, you will receive the following confirmation:

“The php.ini has been written.”

That’s it. Now, we need to restart apache to make sure the new changes took effect. That’s easy too. Do the following to restart apache:

1) Go to the “Home” screen of WHM.

2) Click “Restart Services”

3) Click HTTP Server (Apache)

4) Click yes.

That’s it. Now apache has restarted and will read the new php.ini settings.

If you still receive the same error, go back and do all of these steps again, increasing by another 32M. We do not recommend going above 128M. If a script needs more than that, then chances are there is something wrong with the script and you will need to contact the developer to ask why it is requesting so much php memory.

Method #2 Shell

1) Login to shell using putty or any other SSH tool as the user root

2) modify the php.ini

vi /usr/lib/local/php.ini

3) Look for “Memory limit”

4) Increase the memory limit from the current setting to 32M more. So if it was currently set at 64M, change it to 96M

5) Save the changes.

6) Restart apache:

service httpd restart

That’s it! Thank you!