Question: Website hosted in Plesk is displayed incorrectly, shows 503 Internal Server Error or returns a PHP warning: Failed to read session data
Applicable to:SymptomsWebsite hosted in Plesk is displayed incorrectly, shows HTTP ERROR 500, it's not possible to log in to the PHP application and/or the following error might be found on the Apache log file /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) ... 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 2mod_fcgid: stderr: PHP Warning: session_start(): open(/var/lib/php/sessions/sess_g0u8u3b1j8t98v0jpjmh0gmp84, O_RDWR) failed: No such file or directory (2) ... 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 0CauseThe PHP session directory is missing, has invalid permissions and/or invalid SELinux context.
Resolution1.Log in to Plesk GUI
2.Go to Domains > example.com > PHP Settings and check the value of the parameter session.save_path
Note: If the session.save_path is not set, the session files are saved in the following locations:
- On Ubuntu or Debian OS-based: /var/lib/php7
- On RHEL or CentOS OS-based: /var/lib/php/session
3.Connect to the server via SSH
4.Create and/or set the proper permissions to the PHP session folder. For example, if the session path is /var/lib/php/session:
# mkdir -p /var/lib/php/session && chmod 1733 /var/lib/php/session
5.On RHEL or CentOS OS-based with SELinux enabled, restore the SELinux context with the following command:
# restorecon -R -v /var/lib/php/session