I recently found out that the directory we kept PHP session files had more than 2 million files. Now that's a lot of files and even though it is less than ~55 million maximum allowed on a typical linux system, we had to act fast. On Linux boxes number of files allowed is determined by the number of inodes and this can be viewed with the following command:
$ df -i
Which will give you number of inodes you are using and how much more you can use.
I went through PHP documents on sessions and checked our PHP configuration file php.ini. It turns out that Debian systems does not want PHP to do its garbage collection itself and tries to remove old sessions using a simple cron job. The problem was we were using another directory for storing sessions and not the default "/var/lib/php5". So PHP wasn't removing old sessions because "session.gc_probability" was set to 0 by Debian and Debian cron job wasn't removing these sessions because the sessions were not in their default location. We enabled PHP's garbage collector and modified the cron job so that it uses the correct folder now. Now we have two checks in place for removing old sessions.
This is something to keep in mind if you find yourself with a lot of session files. Hope this helps others.
I have lost sometime trying to solve these errors so I better document it here. So, if you are running phpunit but getting errors of the sort:
PHP Fatal error: Cannot redeclare class Config in /opt/local/lib/php/PEAR/Config.php on line 44
PHP Stack trace:
PHP 1. {main}() /opt/local/lib/php/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /opt/local/lib/php/bin/phpunit:52
...
Then you can get rid of this error by simply deleting the Config.php file inside the PEAR directory. Config library inside PEAR directory is not up to date it seems, with many deprecation warnings also being shown. After you remove the Config.php file everything should be good to go.
On an unrelated note, "php --ini" shows you the ini files used by php and "php --ri xdebug" for example shows you information about the xdebug module. These commands are indispensable if you are trying to troubleshoot your php problems.
