PHP 警告权限在 session_start() 上被拒绝 (13)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6821532/
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
PHP Warning Permission denied (13) on session_start()
提问by Basic Bridge
Possible Duplicate:
How can I fix the Permission error when I call session_start()?
I'm getting the following error:
我收到以下错误:
PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: open(/tmp/sess_49a20cbe1ef09a2d0262b3f7eb842e7b, O_RDWR) failed: Permission denied (13) in /home/------/public_html/includes/libs/ss.inc.php on line 1
The problem doesn't happen all the time, but comes and goes.
问题并非一直发生,而是来来去去。
This the code at line on 1 in ss.inc.php
这是 ss.inc.php 中第 1 行的代码
<?php session_start(); ?>
回答by Peter Rowell
You don't appear to have write permission to the /tmp
directory on your server. This is a bit weird, but you can work around it. Beforethe call to session_start()
put in a call to session_save_path()
and give it the name of a directory writable by the server. Details are here.
您似乎没有/tmp
对服务器上的目录的写权限。这有点奇怪,但你可以解决它。之前调用session_start()
投入到呼叫session_save_path()
,并给它由服务器写入的目录的名称。详细信息在这里。
回答by marcelog
do a phpinfo(), and look for session.save_path. the directory there needs to have the correct permissions for the user and/or group that your webserver runs as
执行 phpinfo(),然后查找 session.save_path。那里的目录需要对您的网络服务器运行的用户和/或组具有正确的权限
回答by Phil
I have had this issue before, you need more than the standard 755
or 644
permission to store the $_SESSION
information. You need to be able to write to that file as that is how it remembers.
我以前遇到过这个问题,您需要的不仅仅是存储信息的标准755
或644
权限$_SESSION
。您需要能够写入该文件,因为它是这样记住的。
回答by Dor
It seems that you don't have WRITE permission on /tmp
.
您似乎没有 WRITE 权限/tmp
。
Edit the configuration variable session.save_pathwith the function session_save_path()to 1 directory abovepublic_html
(so external users wouldn't access the info).
使用函数session_save_path()将配置变量session.save_path编辑到上面的 1 个目录(因此外部用户不会访问信息)。public_html
回答by Dor
PHP does not have permissions to write on /tmp directory. You need to use chmod
command to open /tmp permissions.
PHP 无权写入 /tmp 目录。您需要使用chmod
命令来打开 /tmp 权限。