Applicable to:
- Plesk for Linux
Symptoms
-
Website hosted in Plesk displayed incorrectly or showing the 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
error_log
for the website:# tail -f /var/www/vhost/system/example.com/logs/error_log
...
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 0OR:
# tail -f /var/www/vhost/system/example.com/logs/error_log
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 for PHP session directory are incorrect or 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/php5, 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 issue persists, disable SELinux:
# setenforce 0
Comments
6 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.
Please sign in to leave a comment.