Allowed memory size exhausted when installing a PECL module

Posted Mar. 21, 2008 in PHP

When attempting to install the timezonedb PECL module on one of the CentOS servers I manage, I got the following error message:

# pecl install timezonedb
downloading timezonedb-2007.11.tgz ...
Starting to download timezonedb-2007.11.tgz (180,439 bytes)
..........................done: 180,439 bytes

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 92160 bytes) in /usr/share/pear/PEAR/Builder.php on line 313

I checked the /etc/php.ini file and found that the memory setting was to allow up to 16MB to be used by PHP, yet the error was saying that it ran out of memory at 8MB, which was a little surprising. I adjusted the "memory_limit" setting in the php.ini file to 64MB, just in case, and tried again only to get the same error.

I then ran "php -i" to see what the configuration settings the PHP CLI thought it was using, and it reported that it was set to 64MB:

memory_limit => 64M => 64M

I tried hacking the offending file to add an "ini_set('memory_limit', 64MB);" line in the function that raised the error message but still got the error message.

So I searched Google and discovered there's another way to install PECL modules, which is like so:

cd /tmp
tar -zxf timezonedb-2007.11.tgz
cd timezonedb-2007.11
make install

You can substitute the timezonedb-2007.11.tgz etc in the above for the package you are attempting to install. After you've successfully installed the module, you need to load it by adding the following to you php.ini file:

(again using the module you have installed rather than and then reload Apache like so:

/etc/init.d/apache reload

and your module should now be usable. In order to do this, you need to have the PHP development package installed.