PHP garbage collector lacking permission - [STDERR] PHP Notice: session_start(): ps_files_cleanup_d

try

chown -R nobody:nogroup /var/lib/php/sessions

That did not work.

2021-11-06 13:36:22.668519 [NOTICE] [2026694] [172.70.82.44:31662-1#restorecord.com] [STDERR] PHP Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/lsphp/session/lsphp80) failed: Permission denied (13) in /home/restorecord.com/public_html/includes/functions.php on line 4

Also, I’m confused. My session files aren’t in /var/lib/php/sessions, they’re in /var/lib/lsphp/session/lsphp80. Not only does it say this in logs, I can see them there in FileZilla. The folder /var/lib/php/sessions is empty.

So, after the command you sent didn’t work. I tried chown -R nobody:nogroup /var/lib/lsphp/session. That made it so I couldn’t login. So, I deleted /var/lib/lsphp/session, created it again with FileZilla and created the lsphp80 folder and assigned it the 773 permission. After that I’m still getting the same error. Keep in mind until today, I had not modified the session folder and I was still getting this error with the default cyberpanel installed.

2021-11-06 14:07:03.399008 [NOTICE] [2026696] [172.70.82.226:55964#restorecord.com] [STDERR] PHP Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/lsphp/session/lsphp80) failed: Permission denied (13) in /home/restorecord.com/public_html/verify/index.php on line 5

Looking forward to your response. CyberPanel is great in all other aspects though if I keep having to clear out session files manually that will make it a huge deal breaker.

1 Like

do you have example PHP script to test this ? or I just need to do a session_start() ?

Just need to do session_start(); it’s the PHP garbage collector which runs depending on the probability and divisor. it’s supposed to delete expired session files, though the above permissions error occurs. I have this one site where I did delete the session folder and recreated because it was using all the storage, though I also have another site which until today I hadn’t modified the session folder, and it was still getting this error too. using the normal openlitespeed, not enterprise.

emmmmm , just set up ubuntu 20 + ols + lsphp80 , and with example #1 code from PHP: session_start - Manual

still can’t see the error

did i miss any step to reproduce it ?

maybe you don’t have garbage collector set to run enough. I’ve set session.gc_probability = 5 and session.gc_divisor = 100, as it wasn’t running enough before. Now it runs enough, but it gets that above-mentioned error.

@usmannasir still experiencing issues with this. do you have any ideas? it was happening on my second website too before me making any changes

I tried the solution here PHP Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/session) failed: Permission - #3 by Zalcig by doing chmod -R 1773 session within /var/lib/lsphp

2021-11-13 12:49:10.342335 [NOTICE] [35886] [172.68.110.131:22652:HTTP2-3#keyauth.com] [STDERR] PHP Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/lsphp/session/lsphp80) failed: Permission denied (13) in /home/keyauth.com/public_html/dashboard/index.php on line 2

It did not work, still recieving this error. It did however change something relative to doing this command

root@keyauth:/var/lib/lsphp/session# ls -ld *
drwxrwx-wt 2 root root     4096 Oct  7 18:02 lsphp72
drwxrwx-wt 2 root root     4096 Nov 12 09:26 lsphp73
drwxrwx-wt 2 root root     4096 Nov  6 13:50 lsphp74
drwxrwx-wx 2 root root 34611200 Nov 13 12:36 lsphp80

the lsphp80 directory used to be blue with green background, while the others were black with green background, which I’ve learnt means the lsphp80 directory was not stickied. This probably happened the first time I had to delete and recreate the folder when the size became too large.

And once again this error is ocurring on my other server where until last week when you told me to try a command and it didn’t work and I had to delete directory, I had not modified any folders. So I’m not sure what to tell you as this happened straight from the start before I made any changes to permissions or directories.

@usmannasir hey I’m still experiencing issues with this, do you have any ideas?

Have you tried replicating this same issue in another server setup? Please let me know if its fixed already.

Yes I have. I have two VPS’ with Ubuntu 20.04. The first one I had to delete the session file directory because it was too filled, and I only could see the permissions error after I increased the garbage collector divisor and probability. The second one I could see the permissions error right away before changing any permissions like usmansir. And yes this is still occuring, hopefully there’s a fix to this so I can continue to use cyberpanel

What I’m trying to say is that I didn’t modify permissions on the second VPS until usmansir told me to. And still, it wasn’t working before changing permissions either. The folders were at first left alone and nothing was modified, and the garbage collector was still unable to cleanup expired sessions.

I will have a check and revert soon.

Thank you, looking forward to what you find. I’m still expirencing this error.

Sorry I didnt get time to check the same as was busy with family.
Will test soon.

Hi @mak , did you resolve the problem? I have the last version of Cybepanel and Ubuntu 20.04.4 and still getting the same problem.
This problem has been persistent at least from version 2.0.0 and in my case is generated when a plugin tries to access ps_files_cleanup_dir.

PHP Notice: session_start(): ps_files_cleanup_dir: opendir(/var/lib/lsphp/session/lsphp74) failed: Permission denied (13) in /home/abc.cl/public_html/wp-content/plugins/transbank-webpay-plus-rest/webpay-rest.php on line 82

Sadly not. I realized there wasn’t much benefits to using Cyberpanel in my scenario at least. I’m now using Nginx, this guide is very easy to follow How To Install Linux, Nginx, MySQL, PHP (LEMP) stack On CentOS 7 | DigitalOcean

Make sure you do sudo chown -R root:nginx /var/lib/php/session/ after completing the tutorial. I’ve been running this configuration for several months now and I’ve had no issues :+1:

1 Like

Thank you for your response Mak.
Hello @die2mrw007 , would you recommend us any other configuration to fix this? Shouldn’t this problem come resolved by default after Cyberpanel installation?

Thank you very much in advance!

It should, but it doesn’t seem it is. You could try another server OS perhaps. CentOS7 is quite solid. If it still has this issue on CentOS7, then you should likely use another software. Anything nginx related is better, nginx has the best resilience to DDoS attacks and high use.

Nginx is better is debatable and its all a personal choice afterall. I prefer Litespeed and Openlitespeed more than Nginx and Apache2 stack for its reliability, better performance, ease of use, full apache support which is widely used.

Nginx fails at large ecommerce sites. Nginx still doesn’t have support for HTTP3 QUIC protocol. Many useful features which otherwise are available in other web technology is behind paywall named Nginx Plus. A lot other negative aspects are there.

I am not saying Nginx is completely bad, but I will prefer it only if Litespeed/openlitespeed is not available for any reason my next immediate alternative choice would be Nginx itself.

Also, regarding this particular issue how can I reproduce the same in my test server? I will check it today.