APC warnings: M/G suffixes

Fix APC warnings complaining about M/G suffixes.

The problem

The following line gets printed everytime PHP starts (either in your log, in the command line, etc.):

PHP Warning:  PHP Startup: apc.shm_size now uses M/G suffixes, please update your ini files in Unknown on line 0

It means that in your php.ini file, the value of the key apc.shm_size doesn't have a unit suffix: M for megabyte or G for gigabyte.

The fix

Locate your php.ini file. You may have two of them: one for the web server, the other for the command line (CLI).

First, for the web server. If you don't know where it is, you can make a phpinfo page

echo "<?php phpinfo();" > /var/www/phpinfo.php

Then visit it at http://localhost/phpinfo.php and look for the string php.ini in the page.

Then, for the command line php.ini, the equivalent of phpinfo() is php -i:

$ php -i | grep ini
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d

Look for apc keys in both php.ini. If you can't find it, PHP scans a directory (you can find which with phpinfo() or php -i) for addtional .ini files.

$ grep apc /etc/php5/cli/conf.d/*

Then edit the key apc.shm_size to add the M size suffix:

Quentin Pleplé
June 2013