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/*
/etc/php5/cli/conf.d/apc.ini:extension=apc.so
/etc/php5/cli/conf.d/apc.ini:apc.enabled=1
/etc/php5/cli/conf.d/apc.ini:apc.shm_size=30

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

apc.shm_size=30M
Quentin Pleplé
June 2013