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
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.