Menu Close

PHP 操作文件没有权限:Permission denied

在本地使用PHP脚本操作文件可以成功,等放到服务器上就不行。
查看apache日志:

#cd /var/log/httpd
#tac error_log

解决

1.查看apache配置的用户和用户组

#vi /etc/httpd/conf/httpd.conf
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User  apache
Group apache

可以看到User和Group 都是 apache。

修改你要操作的文件夹用户和权限,将用户就改为和apache配置一样,将权限修改为755:

#chown -R apache:apache /webdata
#chmod -R 755 /webdata

来源链接:https://blog.csdn.net/SeanHuang1661/article/details/51568226

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注