Increase PHP memory limit

If you have seen an error like “Fatal Error: PHP Allowed Memory Size Exhausted” in apache logs or in your browser, this means that PHP has exhausted the maximum memory limit. This post will show 3 different ways on how you can increase the php memory limit and also explain when you should use them.

First, let’s see where is this limit coming from. Normally you will see from the error message what is the actual limit, as this will look like:
PHP Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y) in whatever.php
The default value might differ depending on what php version and linux distribution you are running, but normally this will be set to either 8M or 16M. For example on my debian etch, running on php 5.2 this is set by default at 16M.

In order to identify the current value on your system, look inside your php.ini and search for memory_limit:
memory_limit = 16M ; Maximum amount of memory a script may consume (16MB)

There are three ways to change this value, the obvious way - changing the global value from php.ini, but also an individual method to change it just for a script, or folder. Read the rest of this entry »

Tags: ,

PHP5 in CPanel/WHM

After a long time being supported only as beta (and this by CPanel meaning no support at all), CPanel is finally offering full support for PHP5 on all its latest versions - 10.8.2 - (Stable/Release/Current). I have been using PHP5 on some CPanel servers for a long time without any problems, but now probably they will push towards making this the default choice. Still PHP 4.4.2 is the default version that CPanel will install, but I assume that this will change soon. So it might be a good idea to try to upgrade to PHP5 (or start updating your applications to work on PHP5 as this will soon be needed).

We can choose from various versions of PHP5: 5.0.4, 5.0.5, 5.1.2, 5.1.4… Hmm I feel that they could have added some more :-). My choice was (as I assume most of the peoples will do) the latest version available PHP 5.1.4… Anyway I have not seen any problems on the servers I am using php5 (centos/rhel) besides some application incompatibilities that are being worked on by the developers.

To upgrade your CPanel to PHP5 just use the regular buildapache method. For more details you can see my previous post: “Upgrade php on CPanel/WHM”.

Tags: ,