Every installation of PHP comes with default settings which are usually fine for most websites. Occasionally, the needs of a website makes 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 would need to 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 will 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 the needs of your site.
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 and this 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 affect 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:
- Log into your WordPress site via FTP or SSH.
- Make sure you're in your site's directory. You'll see your wp-config.php file here.
- 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:
- php.ini overview
- SSH overview
- How do I enable PHP error logging?
- How do I increase the PHP upload limit?
- How do I enable PHP extensions and loaders?
- How do I make global phprc changes on a Dedicated Server?
- My phprc file isn't updating
- Where can I view PHP errors and warnings?
- Cannot modify header information