How to increase PHP Memory Limit in cPanel

Sometimes when you execute a PHP script, you will notice that it returns an error like “Fatal Error: Allowed memory size of xxxxxx bytes exhausted”. This is because the amount of memory allocated to the php script has exhausted, and hence the script cannot finish execution. It’s already known as PHP Memory Limit.

The amount of memory available to PHP is defined by the term memory_limit in your server’s PHP settings. With the help of cPanel, you can change this value to anything you like. How that can be done is described below.

First, login to your cPanel account using your cPanel username and Password. If you forgot the password, you can reset it using the ‘Reset Password’ option in the same page.



Once you are in the dashboard, go to Software -> Select PHP Version.



Click on it and it will take you to an interface where you can change the PHP version and select/deselect extensions. To the top right side of the page, you will see another option ‘Switch to PHP Options’.



Click on it and you will be welcomed by an interface which displays the various PHP variables and its associated values. They will be greyed out by default. To change the PHP memory limit, click on the value to the right side of memory_limit. A drop down will appear with possible values you can choose. Select the value you require and hit ‘Apply’. After that scroll down to the bottom and click on ‘Save’. Only then the changes will be fully applied.


php memory limit

You can confirm whether your changes have got into effect by creating a php file with the following contents in it. Suppose I create a file named info.php. Enter the following into it.


Save the file and upload it into your domain’s public_html folder. My domain name is and once uploaded, I can view the file as You can now see your PHP settings in the browser by simply accessing in a browser. Search for the option ‘memory_limit’ to confirm whether the new value you modified has taken effect. In my case, it is correctly showing it as 256M as displayed in the image below.

memory limit

Hope this helps anyone who is worried about the memory limit errors on their website. Changing the values can be easily done via cPanel as explained above.



Leave a Reply

Your email address will not be published. Required fields are marked *