Applicable to:
- Plesk for Linux
Symptoms
Website 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
:
CONFIG_TEXT: 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 2
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) ... 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
- NextCloud applications installed by NextCloud Plesk extension fails the autologin with the following error message:
PLESK_ERROR: Error: Autologin failed
Deploy the following script with the name plesksupport.php
and the previous session data will not remain:
CONFIG_TEXT: <h1>PHP Session</h1>
<form method="post" action="./">
<input type="submit" name="Reset" value="Reset"/>
</form>
<form method="post" action="./plesksupport.php">
<label for="name">$_SESSION: </label>
<input type="text" name="plesksupport" placeholder="Session value" required/>
<input type="submit" name="Submit"/>
</form>
<hr>
<?php
echo '- session.gc_maxlifetime: '.ini_get("session.gc_maxlifetime").'<br>';
echo '- session.save_path: '.ini_get("session.save_path").'<br>';
session_start();
if (isset($_POST['Reset'])) {
session_destroy();
echo '<h3>Session destroyed!</h3>';
}
else {
if (isset($_SESSION['plesksupport'])) {
echo '<h3>Previous Session: '.$_SESSION['plesksupport'].'</h3>';
}
else {
echo '<h3>No Previous Session</h3>';
}
if (isset($_POST['Submit'])) {
echo '<hr>';
$_SESSION['plesksupport'] = $_POST['plesksupport'];
echo 'New Session value: '.$_SESSION['plesksupport'];
echo '<br>';
echo 'POST value: '.$_POST['plesksupport'];
}
}
?>
Cause
The PHP session directory is missing, has invalid permissions and/or invalid SELinux context.
Resolution
-
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
-
-
Connect to the server via SSH
-
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
On RHEL or CentOS OS-based with SELinux enabled, restore the SELinux context with the following command:
# restorecon -R -v /var/lib/php/session
Comments
0 comments
Please sign in to leave a comment.