Applicable to:
- Plesk for Linux
Symptoms
-
Website hosted in Plesk displayed incorrectly, shows HTTP ERROR 500 or returns the following PHP warning:
CONFIG_TEXT: PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/sessions) in Unknown on line 0
-
The following errors are found in Apache
/var/www/vhost/system/example.com/logs/error_log
for the website:CONFIG_TEXT: # mod_fcgid: stderr: PHP Warning: session_start(): open(/var/lib/php/sessions/sess_g0u8u3b1j8t98v0jpjmh0gmp84, O_RDWR) failed: No such file or directory (2) in /opt/www/vhost/example.com/httpdocs/wp-content/plugins/custom-sidebars/inc/external/wpmu-lib/inc/class-thelib.php on line 114, referer: http://example.com/
...
mod_fcgid: stderr: PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/lib/php/sessions) in Unknown on line 0
CONFIG_TEXT: AH01071: Got error 'PHP message: PHP Warning: session_start(): open(/var/lib/php/session/sess_d3deadbeef8i0455babecafeuo, O_RDWR) failed: Permission denied (13) in /home/www-data/example.com/httpdocs/index.php on line 2\nPHP message: PHP Warning: session_start(): Failed to read session data: files (path: /var/lib/php/session) in /home/www-data/example.com/httpdocs/index.php on line 2
Cause
The permissions/SELinux context for the PHP session directory are incorrect or the directory does not exist.
Resolution
-
Log in to Plesk and check the current
session.save_path
for domain in Domains > example.com > PHP Settings.Note: On Ubuntu or Debian, if
session.save_path
is not set, then session files are saved in /var/lib/php7, on RHEL and CentOS systems, ifsession.save_path
is not set, session files will be saved in /var/lib/php/session. -
Connect to the server via SSH and make sure the directory exists and have proper permissions (1733). If path is
/var/lib/php/session
:# stat /var/lib/php/session | grep Access
Access: (1733/drwx-wx-wt) Uid: ( 0/ root) Gid: ( 0/ root)If directory does not exists create it and set valid permissions:
# mkdir -p /var/lib/php/session && chmod 1733 /var/lib/php/session
If directory exists but permissions are different, set the correct ones:
# chmod 1733 /var/lib/php/session
Note: If the directory exists and its permissions are correct, restore the SElinux context:
# restorecon -R -v /var/lib/php/session
Comments
10 comments
I am suffering from the same issue and I use CentOs system. I cross check session.save_path through phpinfo(); it shows /var/lib/php/session.
I rest the permissions for it but still the issue is active. please help me to resolve it.
@Soni, check the permissions and ownership of the folder:
# ls -ld /var/lib/php/session
drwx-wx-wt 2 root root 4096 Nov 6 00:32 /var/lib/php/session
Permission should be 1733
Should it be session or sessions? In centos it is session. Above you have sessions?
Hi @Justin Lnch,
Ubuntu, Debian - /var/lib/php/sessions/
CentOS - /var/lib/php/session/
Your answers here helps me, but i have added the directory given inside SFTP root not on the FTP and it resolved my issues. Thanks so much guys, i hope this input also helps others
Hi,
I am using Suse 12, And there is /var/lib/php7 folder but no session folder is there so should i create a new session directory and set permission to 1733.
Please help me.
I have encountered this issue, and the permissions and ownership appear as above for the PHP session directory, and I've confirmed the directory is named as such in the PHP configuration. The resolution of setenforce 0 works, but is apparently needs to be set frequently because the permissions issue reappears. Is there a permanent solution?
Hello James,
If the disabling SELinux resolves the issue, there is possibility that the context on the /var/lib/php/session is insufficient. As far as I understood permission/ownership on directory is also got reset. The both issue require deep investigating. Please, submit request to support for further investigating. On how to do so check the article: https://support.plesk.com/hc/en-us/articles/213608509-How-to-submit-a-request-to-Plesk-support-
The fix for me was:
restorecon -R -v /var/lib/php/session/
Hello Brian Essig,
The utility restorecon is used to restore the default SELinux context.
Indeed, it can cause the issue so I have updated the article with the corresponding changes.
Thank you for the information.
Please sign in to leave a comment.