[乐意黎原创]PHP 写入文件时抛failed to open stream:Permission denied in 错误的解决方法
2017-08-25 16:50
946 查看
乐意黎在做ECS主机里 apache+php7 环境里, 写入json 文件时, 无意中抛Warning: fopen(./***.json): failed to open stream: Permission denied in /usr/local/apache/htdocs/****.php on
line 397
can't open file
错误, 总是感觉很奇怪, 本机或其它远程机,一切正常呀.
如图:
![](https://img-blog.csdn.net/20170825162155698?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWVyY2hp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
此处我是用: CuteFtp 工具来调整目录权限.
该目录的权限如图: 权限为 751. 此权限导致的无法写入
![](https://img-blog.csdn.net/20170825162225653?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWVyY2hp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
把该目录的权限调整为: 757
![](https://img-blog.csdn.net/20170825162308697?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWVyY2hp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
注: 也可以使用 unix 命令.
1. 该PHP应用程序一般针对Linux下的一般用户,目录应具有可读,可写,可执行权限(即777),文件根据相应操作,分配一般用户相应的权限
eg: 文件放在/usr/local/使用出问题的目录/,名为: aerchi.json,文件操作为 'r+'
目录a的权限: chmod 777 aerchi
文件aerchi.json 的权限至少应为: chmod 006 aerchi.json
2. 如果文件在/root/下,即使该文件及其所在目录都具有777的权限,也会出现Permission denied的错误提示
; Defines the default timezone used by the date functions
; http://php.net/date.timezone date.timezone = PRC
![](https://img-blog.csdn.net/20170825164310390?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWVyY2hp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
+
大功造成, 标记一下.
乐意黎原创
2017-08-25
原文地址: http://blog.csdn.net/aerchi/article/details/77575063
line 397
can't open file
错误, 总是感觉很奇怪, 本机或其它远程机,一切正常呀.
1.无权限的处理方法
过程如下:如图:
此处我是用: CuteFtp 工具来调整目录权限.
该目录的权限如图: 权限为 751. 此权限导致的无法写入
把该目录的权限调整为: 757
注: 也可以使用 unix 命令.
1. 该PHP应用程序一般针对Linux下的一般用户,目录应具有可读,可写,可执行权限(即777),文件根据相应操作,分配一般用户相应的权限
eg: 文件放在/usr/local/使用出问题的目录/,名为: aerchi.json,文件操作为 'r+'
目录a的权限: chmod 777 aerchi
文件aerchi.json 的权限至少应为: chmod 006 aerchi.json
2. 如果文件在/root/下,即使该文件及其所在目录都具有777的权限,也会出现Permission denied的错误提示
2. 另外, PHP.ini 调整时区
php7 里的 php.ini 文件里 大概 926 行左右; Defines the default timezone used by the date functions
; http://php.net/date.timezone date.timezone = PRC
+
大功造成, 标记一下.
乐意黎原创
2017-08-25
原文地址: http://blog.csdn.net/aerchi/article/details/77575063
相关文章推荐
- 【解决问题】'failed to open stream:Permission denied in......'在php出现情况总结
- Lamp环境下编写PHP代码时出现错误:Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
- PHP "Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0" 错误
- PHP使用copy函数复制windows文件时出现failed to open stream: Invalid argument in错误
- php错误提示failed to open stream: HTTP request failed!的完美解决方法
- easyhadoop:failed to open stream:Permission denied in /var/www/html/index.php
- php文件上传 [function.move-uploaded-file]: failed to open stream 错误解决办法
- easyhadoop:failed to open stream:Permission denied in /var/www/html/index.php
- php错误提示failed to open stream: HTTP request failed!的完美解决方法
- PHP Warning: file_put_contents(".."):failed to open stream: Permission denied in...
- failed to open stream: Permission denied in
- php上传文件时出现错误:failed to open stream: Permission denied
- linux下的LAMP环境中的问题:failed to open stream: Permission denied in
- 关于写入文件缓存时报"java.io.FileNotFoundException open failed (is a director)"错误的解决方法
- 解决php上传文件过程中Warning move_uploaded_file, failed to open stream的一种思路
- php提示Failed to write session data错误的解决方法
- php错误:failed to open stream: HTTP request failed!
- 解决nginx下connect() to 127.0.0.1:3000 failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: 错误信息
- PHP 上传文件 function move_uploaded_file: failed to open stream
- 使用solr报错,错误信息 include(SolrClient.php): failed to open stream: No such file or directory