Session_start(): ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13)

Hi,

I’m running DreamFactory on Debian and regularly face this error. Not only is it annoying, it also terminates active sessions.
This is something that should not happen unless the PHP-application overrides the “session.gc_probability = 0” setting from the php.ini.

What exactly does DF do here?

On what version of PHP are you running DSP 1.9.1 when you get this error?

This is a common issue on Debian and its derivatives, because Debian uses a cron job for session cleanup rather than leaving it to Apache/PHP like other environments typically do. Typically this error is seen because the default permissions of the sessions directory aren’t configured for this, and eventually there is a garbage collection conflict.

A quick Google search provides two possible ways of resolving this. (There may be more.)

  1. Change permissions on the directory in question.
  2. Edit garbage collection probability setting in php.ini.

A great article has been published on this error particularly. In summary, the error is caused by PHP is trying to delete the session files while this is also being done by a cronjob put on the system by the Debian package maintainers of PHP.

The easiest solution is changing the permissions which is typically www-data:www-data.

chown -R www-data.www-data /var/lib/php5