php遇到failed to open stream: Permission denied

简介: 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不能获取带端口的网址》(www.111cn.net/phper/31/48…


解决办法如下: 例子 输出: This is a test file with test text. 同样此函数还可以用于获取远程服务器上的内容

file_get_contents('www.111cn.net'); 这样也是没有问题,但是如果我带了端口了就有问题了


例如: file_get_contents('http://localhost:12345');



目录
相关文章
|
11月前
|
应用服务中间件 PHP nginx
PHP ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
PHP ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
99 1
|
测试技术 PHP
PHP: PhpStorm单元测试报错:PHPUnit Cannot open file
PHP: PhpStorm单元测试报错:PHPUnit Cannot open file
99 0
|
缓存 PHP 开发工具
Composer 更新时报错:PHP Fatal error: composerRequireac6b4…(): Failed opening required ‘…/src/helpers.php
Composer 更新时报错:PHP Fatal error: composerRequireac6b4…(): Failed opening required ‘…/src/helpers.php
206 0
Composer 更新时报错:PHP Fatal error:  composerRequireac6b4…(): Failed opening required ‘…/src/helpers.php
|
网络安全 PHP
PHP函数file_get_contents()使用 https 协议时报错:SSL operation failed
报错提示: 总之就是https报错,采集不到数据
179 0
|
Apache 网络协议
file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known
请求页面时候报错 file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known , 找了很久都说是找不到DNS服务器,要修改apache配置之类的,最后加上一句set_time_limit(0);就好了。
2577 0
|
1月前
|
数据库
基于PHP+MYSQL开发制作的趣味测试网站源码
基于PHP+MYSQL开发制作的趣味测试网站源码。可在后台提前设置好缘分, 自己手动在数据库里修改数据,数据库里有就会优先查询数据库的信息, 没设置的话第一次查询缘分都是非常好的 95-99,第二次查就比较差 , 所以如果要你女朋友查询你的名字觉得很好 那就得是她第一反应是查和你的缘分, 如果查的是别人,那不好意思,第二个可能是你。
40 3
|
2月前
|
NoSQL 关系型数据库 MySQL
linux服务器重启php,nginx,redis,mysql命令
linux服务器重启php,nginx,redis,mysql命令
46 1
|
3月前
|
关系型数据库 MySQL PHP
|
2月前
|
Ubuntu 关系型数据库 MySQL
ubuntu apt 安装wordpress所需所有的 一键脚本 扩展您的PHP似乎没有安装运行WordPress所必需的MySQL扩展。
ubuntu apt 安装wordpress所需所有的 一键脚本 扩展您的PHP似乎没有安装运行WordPress所必需的MySQL扩展。
37 0
ubuntu apt 安装wordpress所需所有的 一键脚本 扩展您的PHP似乎没有安装运行WordPress所必需的MySQL扩展。