10

I am geting the following error in the Log Files from a Web App (OpenCart). Has anyone seen this? Or can I just ignore this "somewhat known bug"? I tried following other posts regarding this specific error, without success:

PHP Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/session) failed: Permission denied (13)

In that dedicate server's session folder, I see:

-rw------- 1 apache apache  48 Mar  5 19:21 sess_0pl62elpgn43rjakfh6em2v2n5
-rw------- 1 apache apache  48 Mar  5 19:33 sess_2vo41urqek50ef9nl1429879i3
-rw------- 1 apache apache 125 Mar  5 18:59 sess_35goisejg3asq4n4hntcsgofu6
-rw------- 1 apache apache  48 Mar  5 19:16 sess_4cgkdiqfqgfgje356uoem0r7s3
-rw------- 1 apache apache  48 Mar  5 19:33 sess_5ji1i4kppt6ara43v8jdflcgh6
-rw------- 1 apache apache  48 Mar  5 19:34 sess_5sbl2o6ndpphh8jqogrb12v6j1
  .
  .

LAMP, CentOS 5, PHP 5.2

Antony
  • 14,900
  • 10
  • 46
  • 74
user3386483
  • 109
  • 1
  • 1
  • 3

2 Answers2

20

For fixing the ps_files_cleanup_dir: opendir(/var/lib/php/sessions) failed: Permission denied issue I recommend the following two things:

  1. To grant the write access rights for this particular folder (/var/lib/php/sessions) to the operating system.

    $ sudo chmod 755 /var/lib/php/sessions

  2. Another good solution is to set a custom location (which the PHP interpreter can write the session files to) for the session folder with the session.save-path in php.ini.

Note: Disabling the PHP’s session garbage collector with the session.gc_probability=0 PHP setting is not a good solution, because you will have a lot of orphaned session files in the session folder, and it will waste the disk space and slow down your server.

Tahir
  • 483
  • 1
  • 4
  • 17
9

If your httpd server user/group are www-data.www-data then change:

chown -R www-data:www-data /var/lib/php/sessions

This should give httpd server ownership of this directory.

Konrad Gałęzowski
  • 1,761
  • 1
  • 20
  • 29