Friday, November 2, 2012

session_start() [function.session-start]: ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13)



I was working on a CakePHP application that was deployed on a Debian machine when I met this error. Bit of googling told me this error is more common to any app using php on a Debian/Ubuntu machine. So here goes..
 

Problem
If you are seeing this error:

session_start() [function.session-start]: ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13) [CORE/Cake/Model/Datasource/CakeSession.php, line 605]

detailed error:


Notice (8): session_start() [function.session-start]: ps_files_cleanup_dir: opendir(/var/lib/php5) failed: Permission denied (13) [CORE/Cake/Model/Datasource/CakeSession.php, line 605]
Code
            }
        } else {
            session_start();
session_start - [internal], line ??
CakeSession::_startSession() - CORE/Cake/Model/Datasource/CakeSession.php, line 605
CakeSession::start() - CORE/Cake/Model/Datasource/CakeSession.php, line 187
CakeSession::check() - CORE/Cake/Model/Datasource/CakeSession.php, line 213
SessionComponent::check() - CORE/Cake/Controller/Component/SessionComponent.php, line 96
 



Reason

According to online resources it because some package on your Debian/Ubuntu machine is trying to do "Session garbage collection" where it shouldn't.
The session data is stored in /var/lib/php5 and it has the permission of "drwx-wx-wt 2 root root". So those packages cannot read into them.

Solution

The fix is simple: In your php.ini set session.gc_probability to 0 and restart apache

Detailed steps:
  • Find your php.ini usually its at:
    /etc/php5/apache2/php.ini

  • Edit it and find this setting
    session.gc_probability
  • Now set that value to 0
  • Restart apache
    sudo /etc/init.d/apache2 restart

Resources
For more information, read:


No comments :

About Me

Popular Posts

Designed By Seo Blogger Templates