php遇到failed to open stream: Permission denied

Uncaught exception 'think\exception\ErrorException' with message 'error_log(/www/api/public/../runtime/log/201611/29.log): failed to open stream: Permission denied' in /www/api/thinkphp/library/think/log/driver/File.php

当赋权限后当天可以,但是明天生成新的log的时候就又出现这样的问题。(环境时Linux)

解决方法是 :关闭selinux 1 永久方法 – 需要重启服务器

修改/etc/selinux/config文件中设置SELINUX=disabled ,然后重启服务器。

2 临时方法 – 设置系统参数

使用命令

setenforce 0

附:

setenforce 1 设置SELinux 成为enforcing模式

setenforce 0 设置SELinux 成为permissive模式

php的allow_url_fopen选项是关闭了

原因是我们php.ini中把php的allow_url_fopen选项是关闭了,我们只要把它打开即可。

如果你没有权限打开allow_url_fopen的话我们可使用curl函数的来替换,也是很方法的。

修改/etc/selinux/config文件中设置SELINUX=disabled,我是这样解决的

很多网友说是文件夹权限错误,于是通过“chmod -R 777 /你的文件夹”更改所在文件夹的权限,但不起作用,还是报错。

几经痛苦测试排错,发现更换file_get_contents的url:“http://x.x.x.x:9898/aa/bb/cc.php”,发现不带端口的file_get_contents是正常的,所以肯定不是文件夹的权限问题,

再通过网友写的《file_get_contents不能获取带端口的网址》(http://www.111cn.net/phper/31/48374.htm),最终顺利解决。

解决办法如下: 例子 输出: This is a test file with test text. 同样此函数还可以用于获取远程服务器上的内容 file_get_contents('http://www.111cn.net'); 这样也是没有问题,但是如果我带了端口了就有问题了

例如: file_get_contents('http://localhost:12345'); --------------------- 本文来自 qhgseeg 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/qhgseeg/article/details/70785654?utm_source=copy

http://www.thinkphp.cn/topic/44110.html

猜你喜欢

转载自blog.csdn.net/daily886/article/details/82803554