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

Hello,

I’m using cyberpanel with openlitespeed and I’ve been recieving this error

[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

How do I fix it? I’ve looked at several solutions online and none of them have seemed to work so far.

Can you tell me your OS?

Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-88-generic x86_64)

root@cyberpanel-backup-test:/var/lib/lsphp/session# ls -la
total 24
drwxr-xr-x 6 root root 4096 Nov 1 04:52 .
drwxr-xr-x 3 root root 4096 Nov 1 04:52 …
drwx-wx-wt 2 root root 4096 Nov 1 04:52 lsphp72
drwx-wx-wt 2 root root 4096 Nov 3 10:13 lsphp73
drwx-wx-wt 2 root root 4096 Nov 1 04:52 lsphp74
drwx-wx-wt 2 root root 4096 Nov 1 04:52 lsphp80
root@cyberpanel-backup-test:/var/lib/lsphp/session#

Permission for your session folders look like this ?

root@keyauth:/var/lib/lsphp/session# ls -la
total 8604
drwxrwx-wt 6 root root 4096 Oct 31 11:29 .
drwxr-xr-x 3 root root 4096 Oct 7 18:02 …
drwxrwx-wt 2 root root 4096 Oct 7 18:02 lsphp72
drwxrwx-wt 2 root root 4096 Oct 31 14:35 lsphp73
drwxrwx-wt 2 root root 4096 Oct 7 18:02 lsphp74
drwxrwx-wx 2 root root 8785920 Nov 4 15:56 lsphp80

looks like this. I’m guessing I messed up permissions when I deleted and recreated lsphp80 folder a little while ago when I had too many session files. I think I have resolved the root cause of that, by increasing garbage collector probability and divisor, so this looks to be the last step left to solve too many session files from happening again.

Please let me know what command I should do to resolve this, I am new to VPS hosting and don’t want to mess anything up further. Appreciate you helping me with your software, thank you.

If your issue is resolved then its good, and it was definitely a permissions related issue. Anyways later if when I’ve more time I will record a video on how to fix such basic stuff.

No it’s actually not fixed yet. Initially the issue was I didn’t have the garbage collector divisor and probablity low enough, now the issue is that the error below is output when the garbage collector is called.

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 having this issue with my other site on a different VPS using Cyberpanel. I have not deleted the session folder on this server, and it’s still having the same error when trying to cleanup session files as my other site is.

root@restorecord:/var/lib/lsphp/session# ls -la
total 24848
drwxrwx-wt 6 root root 4096 Oct 16 20:08 .
drwxr-xr-x 3 root root 4096 Oct 16 20:08 …
drwxrwx-wt 2 root root 4096 Oct 16 20:08 lsphp72
drwxrwx-wt 2 root root 4096 Nov 4 01:21 lsphp73
drwxrwx-wt 2 root root 4096 Oct 16 20:08 lsphp74
drwxrwx-wt 2 root root 25423872 Nov 5 18:40 lsphp80

Please let me know how to fix the error. Also, when I log into the server with FileZilla and right click the lsphp72, lsphp73, lsphp74, or lsphp80 folders in /var/lib/lsphp/session/, and then click file permissions, they all have the 773 permission. This was done by default, I didn’t modify them to that myself.

I have zero reason to suspect issues occuring on this server too since I have not changed anything. On this server, I just installed cyberpanel and it’s showing the same error as my other server.

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.

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.