How to increase the PHP Memory limit using .htaccess?

By default, a PHP script can allocate up to 128 megabytes of memory. You can modify this limit by changing the memory_limit directive in an .htaccess file.

To change the PHP memory limit, follow these steps:

Step1 > Login to cPanel
Then go to File Manager from cPanel.

Step 2 >Now go to your document root and open .htaccess file by right-click. Then click on the “Edit”

Step3 >Now put the following code. Replace xxx with the new memory limit value that you want to set, in megabytes:
php_value memory_limit xxxM

Step 4 >Save the changes to the .htaccess file and exit the text editor.

Step5 >To verify that the new setting is active, create a PHP test file that contains the following code in the same directory where the .htaccess file is located:

<?php phpinfo(); ?>

Was this article helpful?

Related Articles