Last updated December 24, 2014. Created on January 6, 2008.
Edited by joachim, Christopher James Francis Rodgers, bserem, 1q84. Log in to edit this page.

Note: increasing PHP

'Php-Memory limit' is different from increasing 'PHP-upload' size limit.

You can learn to increase upload size on page: here.

The standard PHP memory requirements for Drupal core are a bare minimum. Sites that run many contrib modules, or particularly memory-intensive ones, will need more. There are several techniques to increase the PHP memory limit and you only need to use one of them. The right one for you depends on your system configuration.


This is the recommended approach if you have access to the server's php.ini. This will not be possible in some shared hosting environments, though your host may be able to adjust it for you. Note that this change will affect all websites and PHP scripts on the server.

  1. Locate the php.ini file used by your web server. You can click the "more information" link on Drupal's status page's PHP section. which shows the phpinfo() page. Locate the Configuration File (php.ini) Path row on that page. During installation Drupal checks the PHP Memory Limit, and if it is less than 32M (16MB for Drupal 6), an error message also provides the path to the php.ini file.
  2. Edit the memory_limit parameter in the php.ini file (usually in a section called Resource Limits)
    memory_limit = 64M ; Maximum amount of memory a script may consume (64MB)
    If there is no section already for this, place the above line at the end of the file.
  3. Restart Apache.

php.ini in the Drupal root folder

Add the following line to a php.ini file in your Drupal root folder:
memory_limit = 64M
This will only work if PHP is running as CGI/FastCGI.

.user.ini in public_html folder (for PHP 5.3 and up)

PHP 5.3+ allows you to change the memory limit by placing a .user.ini file in the public_html folder.
Simply create the above file and type the following line in it:
memory_limit = 64M
Some cPanel hosts only accept this method.

The next two solutions are more restricted in scope and, in some cases, may be more appropriate choices than affecting all sites.


Edit the .htaccess file in the Drupal root directory. Look for the section:

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

and immediately after this add the following line:
php_value memory_limit 64M

This method will only work if PHP is running as an Apache module.


If Drupal is already installed, you can edit sites/default/settings.php. This method will affect only the site using this file.
Locate the PHP settings section and add the following line at the end of that section:
ini_set('memory_limit', '64M');

Shared Hosting

In some shared hosting environments, access to the PHP memory limit setting is restricted. If you cannot make the change yourself, please ask your hosting provider to adjust it for you, or look for a new host that allows more flexibility.

For some hosts renaming php.ini to php5.ini may be necessary.

Some hosting services require the following line in .htaccess to enable a php.ini file.
suPHP_ConfigPath ~/public_html

For some hosts (CrazyDomains) you may need to add the following lines to the php.ini file (if they are not there already):

Modifying php.ini in local server environments

For MAMP see particularly the "Optional: Adjust PHP's memory limit for scripts" section (note the difference for MAMP Pro).

If you are using XAMPP/WAMP, there may be two PHP.ini files (one under the PHP directory and the other under Apache/bin). To change your memory limit, edit the file in the XAMPP/Apache/bin directory.

Check your change has taken effect

In all cases, it pays to ensure that your change is actually working. Check Drupal's status report to verify that your memory actually is what you want it to be. If your change doesn't seem to be working, double-check the location of php.ini. Some systems have multiple copies of that file in different places. Only one is used and the others are red herrings.


For Drupal 6 you might want to try the Drupal Tweaks module which allows you to increase your PHP memory limit without editing any files.

XHprof is a good solution to find high memory consumption. See this page for more instructions on how to install and use it:

Looking for support? Visit the forums, or join #drupal-support in IRC.


As If’s picture

If you're running a WHM-powered VPS you may find that you do not have permissions to edit PHP.INI directly; the system must do it. In the WHM host control panel, go to Service Configuration > PHP Configuration Editor.

Interactive Worlds and Immersive Obsessions

marclauren007’s picture

In Plesk under that Websites and Domains tab you can click on the domain name in question. Then you will see a PHP Settings tab after clicking on the domain name, this screen will allow you to change the most common PHP settings, including the upload limit.

---Hope this helps

texas-bronius’s picture

In all cases, it pays to ensure that your change is actually working. Use phpinfo to verify that your memory actually is what you want it to be. If your change doesn't seem to be working, double-check the location of php.ini displayed in the phpinfo page. Some systems have multiple copies of that file in different places. Only one is used and the others are red herrings.

To add to confusion, note that at least in the case of, phpinfo() actually responded with the higher memory_limit setting placed in settings.php, however the memory_limit was still the system-enforced 30MB. This observation was confirmed by 1and1 support. Also, fwiw, this memory limit is imposed on concurrent activity on the account overall, not per website on the account.

80s themed Drupal T-Shirts

stevegmag’s picture

1and1 indeed does have a 30M memory limit on their shared plans.

This will run a basic drupal 6 install, but not much more, certainly not a Drupal 6 install with "default" contrib modules (CCK, Veiws, etc..). I thought I had resolved the issue via php.ini, htaccess, or drupal settings as phpinfo will report that you're memory has been increased, but the site memory errors always report that there is only 30M available. I called 1and1 today and confirmed that no such limit is in place on their cloud, VPS, or dedicated plans, but I have not confirmed that in practice yet..


jahmes8’s picture

Try using the file name php5.ini instead.

I found this to work on some hosting providers (GoDaddy, BlueHost among my managed sites). Just putting php.ini in the root didn't change the limit in the Status Report. I renamed it to php5.ini and then it registered.

I hope it helps.

loopduplicate’s picture

I also specify the limit in settings.php like the example below. Do you?

ini_set('memory_limit', '256M');

Christopher James Francis Rodgers’s picture

For a detailed step-by-step solution to the memory error problem
"Fatal error Allowed memory size of"
for both Drupal 6 and Drupal 7 to easily increase the memory allocation to 128M, see...

Drupal 7 Fatal error Allowed memory size of ...


Drupal 7 memory increase to more than 128M,
that may or may not work for Drupal 6, see...

All the best; intended.
-Chris (
"The number one stated objective for Drupal is improving usability." ~Dries Buytaert *

mfby2k’s picture

The setting.php method worked for me know my site run with out the error message. [memory exhausted......] thanks for the info.

Alex v. B.’s picture

sridharpandu’s picture

In PHP.ini I can set memory_limit = -1 to indicate "no memory limit" use all that is available. Can I do this in settings.php ini_set('memory_limit', '-1'); to have the same effect?

Best regards


Acer Aspire 5745
[i5 430M, 3GB, 320GB]
Ubuntu 12.04 (Precise Pangolin)
Drupal 6.15, 7.x
DigitalOcean, Go Daddy, Rackspace,

asb’s picture

@sridharpandu: Maybe you want to try this out? It shouldn't be too hard to change the parameter and go to the status report page.

However, for people running Suhosin patch this setting is neither valid in php.ini nor anywhere else (and is handled as an illegal attack).

sridharpandu’s picture

@asb, I am running all my sites with suhosin! I just used it on one ocassion on a slicehost VPS, I didn't install the suhosin patch though. But as of now all the sites I run have the suhosin patch.

Acer Aspire 5745
[i5 430M, 3GB, 320GB]
Ubuntu 12.04 (Precise Pangolin)
Drupal 6.15, 7.x
DigitalOcean, Go Daddy, Rackspace,

sparcle_z’s picture

php_value memory_limit = "128M"
# added the file as php.ini and loaded in public_html

robwithhair’s picture

I just had this problem while trying to enable a commerce module. admin/modules/confirm gave me an out of memory warning when enabling price module. Surprisingly I had 128MB available in my php.ini but needed more. If anyone has this problem I'd suggest trying to increase the memory limit to something crazy like 512MB temporarily and to disable and re-enable the module again. Worked for me but I couldn't believe I might need more memory than this. Remember to restart apache after adjusting php.ini file. I've put my memory limit down to 128MB again after enabling the module in question.

yevgeny.ananin’s picture


I have 1&1 and they cap their 'Business Linux' shared hosting accounts' php memory limit at 90MB - and they don't offer any accounts with a higher limit. I have recently run into the problem described in these forums:,

I contacted 1&1 and they told me that this error is definitely a php memory error - and that they can't do anything about it. Can anyone recommend a hosting provider who has a higher max php memory limit, like 128M, 256M, or even 512M?

asb’s picture

@yev.ananin: Avoid incompetent managed hosting - if that's what 1&1 is doing, they are incompetent. Go for a root server, or look for a managed hosting that actually supports Drupal. You can find some companies with proven Drupal know-how at the marketplace, or you can drop me an email if you are interested in individual experiences. However, this is not the right place to discuss Drupal hosting, please use the forums for that.

Christopher James Francis Rodgers’s picture

since those all of the links on that page
are drupal® affiliate links
from hosting companies that support Drupal technically;
and financially--
when you use the links on this page:

The "Hosting" page

All the best; intended.
-Chris (
"The number one stated objective for Drupal is improving usability." ~Dries Buytaert *

Christopher James Francis Rodgers’s picture

I have now been happy with BlueHost for 4 years.

Use their link on the page
and BlueHost will give all of the money
from your initial contract (your initial order)
to (..if I understand correctly).

I recommend you buy three years at $4.95 / month (or whatever it is today..)
to avoid the hassle
of renegotiating it down from $7.95 (or whatever it is today..)
when your first contract (your first order) expires.
{They so play hard-ball now... 2013.05}

  • Unlimited website storage
  • Unlimited bandwidth
  • 50 MySQL Databases
    {but restricted to 1000-tables = approximately 7 or 8 Drupal-7 sites}

Using the free BlueHost control panel's
automated Drupal installer
via "SimpleScripts" (I recommend you do not use: Fantastico)
I can 'one-click' install a test Drupal 6 or 7 site;
and the php-memory limit is automatically set to 128M (for Drupal 7).

All the best; intended.
-Chris (
"The number one stated objective for Drupal is improving usability." ~Dries Buytaert *

loopduplicate’s picture

I agree with Christopher James Francis Rodgers about Bluehost (or Hostmonster; they are the same company.) I've been using them for about 3-4 years now. For an inexpensive shared server setup, they are amazing.

ChandeepKhosa’s picture

Just a heads up for anyone using Heart Internet shared hosting reseller account - the only method you can use is adding
php_value memory_limit 128M to the file sites/default/settings.php
A good way to test it is see if the status report changes here /admin/reports/status

ravi_admec’s picture

it is really traumatic sometimes. i had to refresh my site more than 10 times too for clearing the cache in drupal 7.
I tried both method 1. php.ini (memory_limit = 128M) and 2. settings.php (ini_set('memory_limit', '128M');) with recommended settings.

yet i am facing the same issue.

Will some one tell me something useful plz.

My website can be found in my signature.

ravi_admec’s picture

i have to solution and used on one of my websites too.

you can notice in previous comment i posted about how i am puzzled.

create a php5.ini file and put the following line inside that

memory_limit = 256M

and upload in the root of your drupal website.


johnedo’s picture

PHP 5.4 on GoDaddy (ok laugh... it's the clients choice) shared hosting:

I followed the instructions for creating a php.ini file, editing the settings.php with no luck. The thing that finally worked was adding a .user.ini file at the Drupal root folder.

Content of the .user.ini file:

file_uploads = On
post_max_size = 128M
upload_max_filesize = 128M
max_execution_time = 300
memory_limit = 256M
max_input_vars = 3000

file permissions: 0644

classicaldeal’s picture

Hi all,

I had faced same issue for Fatal error: Allowed memory size of 67108864 bytes exhausted on my website
But after changing setting.php file at server side, I have sucessfully increased the PHP memory limit from 64MB to 128MB

here is how to make changes
1.Change permissions of your default directory to 777.
2.add ini_set('memory_limit','128MB'); to setting.php file below #PHP setting section.
3.Check the change has updated or not from Report->status report from Admin section.