Symptoms
- Website hosted in Plesk displayed incorrectly or showing the PHP warning: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 0
OR:
# 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
Causa
The permissions for PHP session directory are incorrect or directory does not exist.
Solución
- Log into 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