PHP出现操作文件没有权限怎么办?

2020-08-12 19:44:05

PHP出现操作文件没有权限的解决办法:首先查看apache配置的用户和用户组;然后修改要操作的文件夹用户和权限,权限修改为755;最后关闭SELINUX即可。

PHP出现操作文件没有权限的解决办法:

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  apacheGroup apache

可以看到User和Group 都是 apache。

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

#chown -R apache:apache your_folder#chmod -R 755 your_folder

3.按理说到这步应该问题就解决了,可是这天使用的是刚装的新系统,SELINUX需要关闭

关闭SELINUX:
#vi /etc/selinux/config#SELINUX=enforcing #注释掉#SELINUXTYPE=targeted #注释掉SELINUX=disabled #增加:wq! #保存退出#setenforce 0 #使配置立即生效
相关文章 大家在看