php 无法写入会话数据(文件)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16022731/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Failed to write session data (files)
提问by
I just ordered a vps server by a hosting party. It's a CentOS with Plesk 11. So i just installed my Zend applicaton on the server but now the error log states
我刚刚通过托管方订购了一个 vps 服务器。这是一个带有 Plesk 11 的 CentOS。所以我刚刚在服务器上安装了我的 Zend 应用程序,但现在错误日志指出
[Mon Apr 15 20:48:28 2013] [warn] [client 94.210.222.87] mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session::start() - /var/www/vhosts/ontwerp.doedels.eu/httpdocs/mvc/libraries/Zend/Session.php(Line:469): Error #2 session_start(): open(/var/www/vhosts/ontwerp.doedels.eu/tmp/sess_t2orkniqjn9rsn9m84d2clsdd1, O_RDWR) failed: Permission denied (13) Array
[Mon Apr 15 20:48:28 2013] [warn] [client 94.210.222.87] mod_fcgid: stderr: /var/www/vhosts/ontwerp.doedels.eu/httpdocs/mvc/libraries/Zend/Session.php(Line:479): Error #2 session_write_close(): open(/var/www/vhosts/ontwerp.doedels.eu/tmp/sess_t2orkniqjn9rsn9m84d2clsdd1, O_RDWR) failed: Permission denied (13) Array
[Mon Apr 15 20:48:28 2013] [warn] [client 94.210.222.87] mod_fcgid: stderr: /var/www/vhosts/ontwerp.doedels.eu/httpdocs/mvc/libraries/Zend/Session.php(Line:479): Error #2 session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/var/www/vhosts/ontwerp.doedels.eu/tmp) Array' in /var/www/vhosts/ontwerp.doedels.eu/httpdocs/mvc/libraries/Zend/Session.php:482
What did i try so far?I tried setting session.save_path to {DOCUMENTROOT}/tmp and {WEBSPACEROOT}/tmp this doens't seem to work.
到目前为止我尝试了什么?我尝试将 session.save_path 设置为 {DOCUMENTROOT}/tmp 和 {WEBSPACEROOT}/tmp 这似乎不起作用。
The phpinfo function says that session.save_path = /var/www/vhosts/ontwerp.doedels.eu/tmp which is the good folder. The path exists and the folder has 777 CHMOD rights.
phpinfo 函数表示 session.save_path = /var/www/vhosts/ontwerp.doedels.eu/tmp 这是一个好文件夹。路径存在且文件夹具有 777 CHMOD 权限。
Work aroundIt seems to work when i set session.save_path = {WEBSPACEROOT}/private/sess That is a folder i made with 777 chmod permissions, yet it doens't seems to be a permanent solution. Since i have to create this folder by every subscription i make.
变通方法 当我设置 session.save_path = {WEBSPACEROOT}/private/sess 时,它似乎工作。这是我使用 777 chmod 权限创建的文件夹,但它似乎不是永久解决方案。因为我必须在每次订阅时创建这个文件夹。
What do i know for sure?
我肯定知道什么?
- The folder is not full
- The folder does exists
- The folder has writing permissions 777
- The folder owner is 0
- Running the server on fastcgi modus
- 文件夹未满
- 文件夹确实存在
- 该文件夹具有写入权限 777
- 文件夹所有者是 0
- 在 fastcgi 模式下运行服务器
采纳答案by chandresh_cool
You need set permission for your var directory. That seems to be the problem.
您需要为 var 目录设置权限。这似乎是问题所在。
回答by Levon
Default ownership may be incorrect on session folder: Example; php-fpm7.0 on Amazon Linux defaults to apache user. If using nginx or other need to switch the folder ownership. Also as a note you have to change the user/group setting in www.conf.
会话文件夹的默认所有权可能不正确:示例;Amazon Linux 上的 php-fpm7.0 默认为 apache 用户。如果使用nginx或者其他需要切换文件夹所有权。另请注意,您必须更改 www.conf 中的用户/组设置。
chown -R root:nginx /var/lib/php/7.0/
sed -i 's/apache/nginx/g' /etc/php-fpm-7.0.d/www.conf
service php-fpm-7.0 restart
回答by S.M. Nat
In Plex panel go to Software > Select PHP Version > Switch to PHP Options. Set session.save_path value to /tmp
在 Plex 面板中,转到软件 > 选择 PHP 版本 > 切换到 PHP 选项。将 session.save_path 值设置为 /tmp
found in https://flagon.digital/blog/others/failed-write-session-data#solution__defaultpath
在https://flagon.digital/blog/others/failed-write-session-data#solution__defaultpath 中找到