+3 votes
in Programming Languages by (4.5k points)

In the error_log file of my website, I see multiple instances of the following error:

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

How can I fix this error?

1 Answer

0 votes
by (20k points)

From the error message, it is obvious that the owner/group of the domain does not have the privilege to access the folder "/var/lib/php/sessions". "root" may be the owner of the folder "/var/lib/php/sessions".

You can try one of the followings to fix the error:

Approach 1: If you have root access, you can run commands "chown" and "chgrp" to change the owner/group of the folder "/var/lib/php/sessions".

Suppose your domain is example.com and the username of this domain is 'abc'.

#chown abc /var/lib/php/sessions

#chgrp abc /var/lib/php/sessions

Approach 2: Create a directory (e.g. sessions) in the home folder of the user of the domain. Edit the php.ini file to set session.save_path to the new directory (e.g. sessions).

In your php.ini file,

session.save_path = /home/abc/sessions

 

...