Increase the PHP memory limit


Every installation of PHP comes with default settings which are usually fine for most websites. Occasionally, the needs of a website make it necessary to adjust these PHP settings. For example, your site may need to increase the memory limit to allow a process to complete. In that case, you must create a php.ini (phprc) file and update this value.

The DreamHost phprc file

The standard term for a PHP configuration file is php.ini. However, DreamHost uses the term phprc file instead. This acts the same way – only the name is different. In this article, only the term phprc is used.

Some variables (in particular, memory_limit, post_max_size, and upload_max_filesize) are subject to internal limitations; increasing them significantly beyond the default values will not work correctly and cause issues with your site.

Why increase the PHP memory limit?

PHP allows a default amount of memory to be used when processing a website. Sometimes, a website needs more than the default amount of memory. If that's the case, you can increase it to fit your site's needs.

You may also receive an error on your site indicating that the memory limit has been reached. It may appear like this:

Fatal error: Allowed memory size of 94371840 bytes exhausted (tried to allocate 5072 bytes)

This error means your site needs more memory than is currently available. If you see an error like this, try increasing your memory limit by 10MB. Then continue to adjust as necessary.

Increasing the PHP memory limit

The default memory limit is 256M, which is usually more than sufficient for most needs. If you need to raise this limit, you must create a phprc file. View the following articles for instructions on how to create a phprc file:

If the file already exists, view the following articles for instructions on how to update it (depending on if you're using an FTP client or SSH):

If you wish to increase this limit, add the following line:

memory_limit = 300M

If you find you're increasing the memory a large amount, it's time to consider moving off of Shared Hosting, as your website has greater needs than Shared Hosting can reliably provide.

Extra step for WordPress sites

If you're running a WordPress site, the setting in your phprc file may not take effect since WordPress is overriding it in your wp-config.php file. To fix this, just update your wp-config.php file with the specific memory limit. For example:

  1. Log into your WordPress site via FTP or SSH.
  2. Make sure you're in your site's directory. You'll see your wp-config.php file here.
  3. Edit this file (using FTP or SSH) to add the following lines. Make sure to add these before the 'wp-settings.php' inclusion. For example:
    define( 'WP_MEMORY_LIMIT', '300M' );
    define( 'WP_MAX_MEMORY_LIMIT', '300M' );
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');

View the following article for further information.

Kill off all running php processes

Make sure to kill running php processes to ensure your new settings take effect.

Confirming your changes

After you've edited the file and killed off all PHP processes, you should check to confirm the values have updated. You can do this by creating a phpinfo.php file.

If you do not see your changes have updated, try killing off your PHP processes again:

See also

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?