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:
Read More

Wednesday, October 31, 2012

Restore deleted PANEL Ubuntu/Debian(Top or Bottom)

I was trying to remove some icon off my Debian desktop's top panel when this happened. I right clicked on that top panel and clicked 'Delete this panel' without thinking much and wooosh.. my panel is no more! :)

The following link outlined these few tips for me to recover my panel

1. gconftool-2 – -shutdown

2. rm -rf ~/.gconf/apps/panel

3. pkill gnome-panel

Reboot


source: http://aftami.wordpress.com/2010/02/13/restore-deleted-panel-ubuntudebiantop-or-bottom/
Read More

Wednesday, October 17, 2012

CakeEmail Error: Call to a member function subject() on a non-object

I was trying this on CakePHP version 2.2.3 Stable. CakePHP has introduced the new CakeEmail replacing the email component. So in order to use it i put this in my controller.

-------------------------------------------------------------
App::uses('CakeEmail', 'Network/Email'); //at the top of page

class MyController extends AppController {

public function test(){
$email = new CakeEmail('smtp');

$result = $email->from('sender@example.com')
->to('you@example.com')
->message('message')
->subject('About')
->send('my message');
->send();

debug($result);
}
-------------------------------------------------------------
When I ran it, it just wouldn't work! As it turns out the problem is with the 'message' function. Some bug is preventing from using it. Just uncomment that and put you message inside send() like this:
        
-------------------------------------------------------------
$email = new CakeEmail('smtp');

$result = $email->from('sender@example.com')
->to('you@example.com')
->message('message')
->subject('About')
//->send('my message'); --> commented out
->send('my message'); --> message was put here
-------------------------------------------------------------
And it works. So here I'm blogging it hoping it would help save someone's day. Cheers
Read More

About Me

Popular Posts

Designed By Seo Blogger Templates